@Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { if (method.getParameterTypes().length == 1 && isA(method.getParameterTypes()[0], String.class) && args.length == 1 && args[0] instanceof String && isMethodOf(method, ConstantsWithLookup.class)) { return invokeGenericMethod(proxy, (String) args[0], method.getReturnType()); } else if (method.getParameterTypes().length != 0) { return null; } Key k = method.getAnnotation(Key.class); Object result = null; if (k != null) { result = buildConstant(k.value(), method); } if (result == null) { result = buildConstant(method.getName(), method); } return result; }
Key keyAnnot = method.getAnnotation(Key.class); if (keyAnnot != null) { key = keyAnnot.value(); } else { Message msg = new KeyGenMessage(method);
Key keyAnnot = method.getAnnotation(Key.class); if (keyAnnot != null) { key = keyAnnot.value(); } else { Message msg = new KeyGenMessage(method);
Key key = method.getAnnotation(Key.class); if (key != null) { return key.value();
Key key = method.getAnnotation(Key.class); if (key != null) { return key.value();
public String getKey() { KeyGeneratorException keyGenException = null; if (key == null) { Key keyAnnot = getAnnotation(Key.class); if (keyAnnot != null) { key = keyAnnot.value(); } else { GenerateKeys keyGenAnnot = getAnnotation(GenerateKeys.class); try { KeyGenerator keyGen = MessageUtils.getKeyGenerator(keyGenAnnot); key = keyGen.generateKey(this); } catch (KeyGeneratorException e) { keyGenException = e; } } } if (key == null) { GenerateKeys keyGenAnnot = getAnnotation(GenerateKeys.class); // If we were unable to get a key, things will fail later. Instead, fail // here where the backtrace has useful information about the cause. throw new RuntimeException("null key on " + getMessageInterface().getQualifiedName() + "." + getMethodName() + ", @GenerateKeys=" + keyGenAnnot + ", defmsg=" + defaultMessage + ", meaning=" + meaning + ", @DefaultMessage=" + getAnnotation(DefaultMessage.class) + ", @Meaning=" + getAnnotation(Meaning.class) + ", override=" + overrideDefault, keyGenException); } return key; }
public String getKey() { KeyGeneratorException keyGenException = null; if (key == null) { Key keyAnnot = getAnnotation(Key.class); if (keyAnnot != null) { key = keyAnnot.value(); } else { GenerateKeys keyGenAnnot = getAnnotation(GenerateKeys.class); try { KeyGenerator keyGen = MessageUtils.getKeyGenerator(keyGenAnnot); key = keyGen.generateKey(this); } catch (KeyGeneratorException e) { keyGenException = e; } } } if (key == null) { GenerateKeys keyGenAnnot = getAnnotation(GenerateKeys.class); // If we were unable to get a key, things will fail later. Instead, fail // here where the backtrace has useful information about the cause. throw new RuntimeException("null key on " + getMessageInterface().getQualifiedName() + "." + getMethodName() + ", @GenerateKeys=" + keyGenAnnot + ", defmsg=" + defaultMessage + ", meaning=" + meaning + ", @DefaultMessage=" + getAnnotation(DefaultMessage.class) + ", @Meaning=" + getAnnotation(Meaning.class) + ", override=" + overrideDefault, keyGenException); } return key; }
@Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { if (!String.class.equals(method.getReturnType())) { return "Invalid return type of the method " + method.toString(); } //first, try to use the annotation if there is one. Key k = method.getAnnotation(Key.class); String result = null; if (k != null) { result = buildMessage(k.value(), method, args); } if (result == null) { result = buildMessage(method.getName(), method, args); } return result; }
/** * Returns a resource key given a method name. * * @param logger TreeLogger instance for logging * @param method method to get key for * @return the key to use for resource lookups or null if unable to get or * compute the key */ protected String getKey(TreeLogger logger, JMethod method) { Key key = method.getAnnotation(Key.class); if (key != null) { return key.value(); } return AnnotationsResource.getKey(logger, keyGenerator, method, isConstants); } }
/** * Returns a resource key given a method name. * * @param logger TreeLogger instance for logging * @param method method to get key for * @return the key to use for resource lookups or null if unable to get or * compute the key */ protected String getKey(TreeLogger logger, JMethod method) { Key key = method.getAnnotation(Key.class); if (key != null) { return key.value(); } return AnnotationsResource.getKey(logger, keyGenerator, method, isConstants); } }
protected String getKey(Method method) { Key key = method.getAnnotation(Key.class); return key != null ? key.value() : method.getName(); }
protected String getKey(Method method) { Key key = method.getAnnotation(Key.class); return key != null ? key.value() : method.getName(); }
public String getKey() { KeyGeneratorException keyGenException = null; if (key == null) { Key keyAnnot = getAnnotation(Key.class); if (keyAnnot != null) { key = keyAnnot.value(); } else { GenerateKeys keyGenAnnot = getAnnotation(GenerateKeys.class); try { KeyGenerator keyGen = MessageUtils.getKeyGenerator(keyGenAnnot); key = keyGen.generateKey(this); } catch (KeyGeneratorException e) { keyGenException = e; } } } if (key == null) { GenerateKeys keyGenAnnot = getAnnotation(GenerateKeys.class); // If we were unable to get a key, things will fail later. Instead, fail // here where the backtrace has useful information about the cause. throw new RuntimeException("null key on " + getMessageInterface().getQualifiedName() + "." + getMethodName() + ", @GenerateKeys=" + keyGenAnnot + ", defmsg=" + defaultMessage + ", meaning=" + meaning + ", @DefaultMessage=" + getAnnotation(DefaultMessage.class) + ", @Meaning=" + getAnnotation(Meaning.class) + ", override=" + overrideDefault, keyGenException); } return key; }