@Override public String getName(Method method) { return fncSupplier.get().getName(method); }
@Override public String getPolyTypeName(Method method) { return fncSupplier.get().getPolyTypeName(method); }
final Method reverseMethod = throughType.getMethod(annotation.reverse()); final Method throughMethod = throughType.getMethod(annotation.through()); final String reversePolymorphicTypeFieldName = getAttributeTypeFromMethod(reverseMethod).isAnnotationPresent(Polymorphic.class) ? getFieldNameConverter().getPolyTypeName(reverseMethod) : null; final String remotePolymorphicTypeFieldName = getAttributeTypeFromMethod(throughMethod).isAnnotationPresent(Polymorphic.class) ? getFieldNameConverter().getPolyTypeName(throughMethod) : null; final String returnField = getFieldNameConverter().getName(throughMethod); final Set<String> selectFields = new LinkedHashSet<String>(); final DatabaseProvider provider = manager.getProvider(); sql.append(" INNER JOIN ").append(remoteTable).append(" r ON t.").append(provider.processID(returnField)).append(" = r.").append(provider.processID(remotePrimaryKeyField)); final String reverseField = provider.processID(getFieldNameConverter().getName(reverseMethod)); sql.append(" WHERE "); if (!selectFields.isEmpty()) {
final Method reverseMethod = throughType.getMethod(annotation.reverse()); final Method throughMethod = throughType.getMethod(annotation.through()); final String reversePolymorphicTypeFieldName = getAttributeTypeFromMethod(reverseMethod).isAnnotationPresent(Polymorphic.class) ? getFieldNameConverter().getPolyTypeName(reverseMethod) : null; final String remotePolymorphicTypeFieldName = getAttributeTypeFromMethod(throughMethod).isAnnotationPresent(Polymorphic.class) ? getFieldNameConverter().getPolyTypeName(throughMethod) : null; final String returnField = getFieldNameConverter().getName(throughMethod); final Set<String> selectFields = new LinkedHashSet<String>(); final DatabaseProvider provider = manager.getProvider(); sql.append(" INNER JOIN ").append(remoteTable).append(" r ON t.").append(provider.processID(returnField)).append(" = r.").append(provider.processID(remotePrimaryKeyField)); final String reverseField = provider.processID(getFieldNameConverter().getName(reverseMethod)); sql.append(" WHERE "); if (!selectFields.isEmpty()) {
Method getCounterPartMethod() { final String name = converter.getName(method); final Class<?> clazz = method.getDeclaringClass(); for (Method other : clazz.getMethods()) { final String otherName = converter.getName(other); if (!other.equals(method) && otherName != null && otherName.equals(name)) { return other; } } return null; }
String attributeName = fieldConverter.getName(method); final Class<?> type = Common.getAttributeTypeFromMethod(method); attributeName = fieldConverter.getPolyTypeName(method);
/** * @see <a href="https://studio.atlassian.com/browse/AO-325">AO-325</a> */ @Deprecated public static String[] getPolymorphicFieldNames(FieldNameConverter converter, Class<? extends RawEntity<?>> from, Class<? extends RawEntity<?>> to) { Set<String> back = new LinkedHashSet<String>(); for (Method method : from.getMethods()) { Class<?> attributeType = getAttributeTypeFromMethod(method); if (attributeType != null && attributeType.isAssignableFrom(to) && attributeType.getAnnotation(Polymorphic.class) != null) { back.add(converter.getPolyTypeName(method)); } } return back.toArray(new String[back.size()]); }
Method getCounterPartMethod() { final String name = converter.getName(method); final Class<?> clazz = method.getDeclaringClass(); for (Method other : clazz.getMethods()) { final String otherName = converter.getName(other); if (!other.equals(method) && otherName != null && otherName.equals(name)) { return other; } } return null; }
String attributeName = fieldConverter.getName(method); final Class<?> type = Common.getAttributeTypeFromMethod(method); attributeName = fieldConverter.getPolyTypeName(method);
/** * @see <a href="https://studio.atlassian.com/browse/AO-325">AO-325</a> */ @Deprecated public static String[] getPolymorphicFieldNames(FieldNameConverter converter, Class<? extends RawEntity<?>> from, Class<? extends RawEntity<?>> to) { Set<String> back = new LinkedHashSet<String>(); for (Method method : from.getMethods()) { Class<?> attributeType = getAttributeTypeFromMethod(method); if (attributeType != null && attributeType.isAssignableFrom(to) && attributeType.getAnnotation(Polymorphic.class) != null) { back.add(converter.getPolyTypeName(method)); } } return back.toArray(new String[back.size()]); }
public static String getPrimaryKeyField(Class<? extends RawEntity<?>> type, FieldNameConverter converter) { final Iterable<Method> methods = MethodFinder.getInstance().findAnnotatedMethods(PrimaryKey.class, type); if (Iterables.isEmpty(methods)) { throw new RuntimeException("Entity " + type.getSimpleName() + " has no primary key field"); } return converter.getName(methods.iterator().next()); }
private String getPolymorphicTypeFieldName(final Method remoteMethod) { final Class<?> attributeType = getAttributeTypeFromMethod(remoteMethod); return attributeType != null && attributeType.isAssignableFrom(getType()) && attributeType.isAnnotationPresent(Polymorphic.class) ? getFieldNameConverter().getPolyTypeName(remoteMethod) : null; }
public static String getPrimaryKeyField(Class<? extends RawEntity<?>> type, FieldNameConverter converter) { final Iterable<Method> methods = MethodFinder.getInstance().findAnnotatedMethods(PrimaryKey.class, type); if (Iterables.isEmpty(methods)) { throw new RuntimeException("Entity " + type.getSimpleName() + " has no primary key field"); } return converter.getName(methods.iterator().next()); }
private String getPolymorphicTypeFieldName(final Method remoteMethod) { final Class<?> attributeType = getAttributeTypeFromMethod(remoteMethod); return attributeType != null && attributeType.isAssignableFrom(getType()) && attributeType.isAnnotationPresent(Polymorphic.class) ? getFieldNameConverter().getPolyTypeName(remoteMethod) : null; }
/** * @see <a href="https://studio.atlassian.com/browse/AO-325">AO-325</a> */ @Deprecated public static String[] getMappingFields(FieldNameConverter converter, Class<? extends RawEntity<?>> from, Class<? extends RawEntity<?>> to) { Set<String> back = new LinkedHashSet<String>(); for (Method method : from.getMethods()) { Class<?> attributeType = getAttributeTypeFromMethod(method); if (attributeType == null) { continue; } if (to.isAssignableFrom(attributeType)) { back.add(converter.getName(method)); } else if (attributeType.getAnnotation(Polymorphic.class) != null && attributeType.isAssignableFrom(to)) { back.add(converter.getName(method)); } } return back.toArray(new String[back.size()]); }
public static String getPolyFieldName(EntityManager em, Class<? extends RawEntity<?>> entityType, String methodName) { return em.getProvider().shorten(em.getFieldNameConverter().getPolyTypeName(findMethod(entityType, methodName))); }
/** * @see <a href="https://studio.atlassian.com/browse/AO-325">AO-325</a> */ @Deprecated public static String[] getMappingFields(FieldNameConverter converter, Class<? extends RawEntity<?>> from, Class<? extends RawEntity<?>> to) { Set<String> back = new LinkedHashSet<String>(); for (Method method : from.getMethods()) { Class<?> attributeType = getAttributeTypeFromMethod(method); if (attributeType == null) { continue; } if (to.isAssignableFrom(attributeType)) { back.add(converter.getName(method)); } else if (attributeType.getAnnotation(Polymorphic.class) != null && attributeType.isAssignableFrom(to)) { back.add(converter.getName(method)); } } return back.toArray(new String[back.size()]); }
@SuppressWarnings("unchecked") private FieldInfo createFieldInfo(String fieldName, Method accessor, Method mutator) { Class fieldType = Common.getAttributeTypeFromMethod(MoreObjects.firstNonNull(accessor, mutator)); AnnotationDelegate annotations = getAnnotations(accessor, mutator); Generator generatorAnnotation = annotations.getAnnotation(Generator.class); return new ImmutableFieldInfo( fieldName, fieldType.isAnnotationPresent(Polymorphic.class) ? nameConverters.getFieldNameConverter().getPolyTypeName(MoreObjects.firstNonNull(accessor, mutator)) : null, accessor, mutator, fieldType, typeManager.getType(fieldType), annotations.isAnnotationPresent(PrimaryKey.class), !annotations.isAnnotationPresent(NotNull.class), annotations.isAnnotationPresent(Transient.class), annotations.isAnnotationPresent(AutoIncrement.class), annotations.isAnnotationPresent(Default.class), generatorAnnotation != null ? generatorAnnotation.value() : null ); }
String name = fieldNameConverter.getName(method); if (name != null) { if (accessorByFieldName.containsKey(name)) { String name = fieldNameConverter.getName(method); if (name != null) { if (mutatorByFieldName.containsKey(name)) { throw new IllegalArgumentException(String.format("Invalid Entity definition. Both %s and %s generate the same table name (%s)", method, mutatorByFieldName.get(name), name)); mutatorByFieldName.put(fieldNameConverter.getName(method), method);
@SuppressWarnings("unchecked") private FieldInfo createFieldInfo(String fieldName, Method accessor, Method mutator) { Class fieldType = Common.getAttributeTypeFromMethod(MoreObjects.firstNonNull(accessor, mutator)); AnnotationDelegate annotations = getAnnotations(accessor, mutator); Generator generatorAnnotation = annotations.getAnnotation(Generator.class); return new ImmutableFieldInfo( fieldName, fieldType.isAnnotationPresent(Polymorphic.class) ? nameConverters.getFieldNameConverter().getPolyTypeName(MoreObjects.firstNonNull(accessor, mutator)) : null, accessor, mutator, fieldType, typeManager.getType(fieldType), annotations.isAnnotationPresent(PrimaryKey.class), !annotations.isAnnotationPresent(NotNull.class), annotations.isAnnotationPresent(Transient.class), annotations.isAnnotationPresent(AutoIncrement.class), annotations.isAnnotationPresent(Default.class), generatorAnnotation != null ? generatorAnnotation.value() : null ); }