Ejemplo n.º 1
0
  private void initialize() {
    this.type = GenericAssociationInfo.associationTypeOf(accessor);
    this.qualifiedName = QualifiedName.fromAccessor(accessor);
    this.immutable = metaInfo.get(Immutable.class) != null;
    this.aggregated = metaInfo.get(Aggregated.class) != null;

    final Queryable queryable = accessor.getAnnotation(Queryable.class);
    this.queryable = queryable == null || queryable.value();
  }
Ejemplo n.º 2
0
  private static void addProperties(
      Map<Type, ValueType> typeMap,
      Class valueTypeClass,
      Class compositeType,
      List<PropertyType> types) {
    for (Method method : valueTypeClass.getDeclaredMethods()) {
      Type returnType = method.getGenericReturnType();
      if (returnType instanceof ParameterizedType
          && ((ParameterizedType) returnType).getRawType().equals(Property.class)) {
        Type propType = ((ParameterizedType) returnType).getActualTypeArguments()[0];
        RDF rdfAnnotation = method.getAnnotation(RDF.class);
        String rdf = rdfAnnotation == null ? null : rdfAnnotation.value();
        Queryable queryableAnnotation = method.getAnnotation(Queryable.class);
        boolean queryable = queryableAnnotation == null || queryableAnnotation.value();
        ValueType propValueType = newValueType(typeMap, propType, valueTypeClass, compositeType);
        PropertyType propertyType =
            new PropertyType(
                QualifiedName.fromMethod(method),
                propValueType,
                rdf,
                queryable,
                PropertyType.PropertyTypeEnum.IMMUTABLE);
        types.add(propertyType);
      }
    }

    // Add methods from subinterface
    for (Type subType : valueTypeClass.getGenericInterfaces()) {
      // Handles generic type variables
      Class subClass;
      if (subType instanceof ParameterizedType) {
        subClass = (Class) ((ParameterizedType) subType).getRawType();
      } else {
        subClass = (Class) subType;
      }

      addProperties(typeMap, subClass, valueTypeClass, types);
    }
  }