コード例 #1
0
ファイル: PropertyParser.java プロジェクト: relgames/Achilles
  public <T> Class<T> inferValueClassForListOrSet(Type genericType, Class<?> entityClass) {
    log.debug(
        "Infer parameterized value class for collection type {} of entity class {} ",
        genericType.toString(),
        entityClass.getCanonicalName());

    Class<T> valueClass;
    if (genericType instanceof ParameterizedType) {
      ParameterizedType pt = (ParameterizedType) genericType;
      Type[] actualTypeArguments = pt.getActualTypeArguments();
      if (actualTypeArguments.length > 0) {
        Type type = actualTypeArguments[actualTypeArguments.length - 1];
        valueClass = getClassFromType(type);
      } else {
        throw new AchillesBeanMappingException(
            "The type '"
                + genericType.getClass().getCanonicalName()
                + "' of the entity '"
                + entityClass.getCanonicalName()
                + "' should be parameterized");
      }
    } else {
      throw new AchillesBeanMappingException(
          "The type '"
              + genericType.getClass().getCanonicalName()
              + "' of the entity '"
              + entityClass.getCanonicalName()
              + "' should be parameterized");
    }

    log.trace("Inferred value class : {}", valueClass.getCanonicalName());

    return valueClass;
  }
コード例 #2
0
ファイル: PropertyParser.java プロジェクト: relgames/Achilles
  private EmbeddedIdProperties extractEmbeddedIdProperties(Class<?> keyClass) {
    log.trace("Parsing compound key class", keyClass.getCanonicalName());
    EmbeddedIdProperties embeddedIdProperties;

    embeddedIdProperties = compoundKeyParser.parseEmbeddedId(keyClass);

    log.trace("Built compound key properties", embeddedIdProperties);
    return embeddedIdProperties;
  }