예제 #1
0
  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
  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;
  }