Example #1
0
  private void parseSimpleCounterConsistencyLevel(
      PropertyParsingContext context, PropertyMeta propertyMeta) {

    log.trace("Parse custom consistency levels for counter property {}", propertyMeta);
    Pair<ConsistencyLevel, ConsistencyLevel> consistencyLevels =
        findConsistencyLevels(context.getCurrentField(), context.getDefaultConsistencyLevels());

    validator.validateConsistencyLevelForCounter(context, consistencyLevels);

    log.trace("Found custom consistency levels : {}", consistencyLevels);
    propertyMeta.setConsistencyLevels(consistencyLevels);
  }
Example #2
0
  public PropertyMeta parse(PropertyParsingContext context) {
    log.debug(
        "Parsing property {} of entity class {}",
        context.getCurrentPropertyName(),
        context.getCurrentEntityClass().getCanonicalName());

    Field field = context.getCurrentField();
    inferPropertyName(context);
    context.setCustomConsistencyLevels(hasConsistencyAnnotation(context.getCurrentField()));

    validator.validateNoDuplicate(context);
    validator.validateIndexIfSet(context);

    Class<?> fieldType = field.getType();
    PropertyMeta propertyMeta;

    if (List.class.isAssignableFrom(fieldType)) {
      propertyMeta = parseListProperty(context);
    } else if (Set.class.isAssignableFrom(fieldType)) {
      propertyMeta = parseSetProperty(context);
    } else if (Map.class.isAssignableFrom(fieldType)) {
      propertyMeta = parseMapProperty(context);
    } else if (Counter.class.isAssignableFrom(fieldType)) {
      propertyMeta = parseCounterProperty(context);
    } else if (context.isEmbeddedId()) {
      propertyMeta = parseEmbeddedId(context);
    } else if (context.isPrimaryKey()) {
      propertyMeta = parseId(context);
    } else {
      propertyMeta = parseSimpleProperty(context);
      String indexName = getIndexName(field);
      if (indexName != null) {
        propertyMeta.setIndexProperties(new IndexProperties(indexName));
      }
    }
    context.getPropertyMetas().put(context.getCurrentPropertyName(), propertyMeta);
    return propertyMeta;
  }
Example #3
0
  protected <K, V> PropertyMeta parseMapProperty(PropertyParsingContext context) {
    log.debug(
        "Parsing property {} as map property of entity class {}",
        context.getCurrentPropertyName(),
        context.getCurrentEntityClass().getCanonicalName());

    Class<?> entityClass = context.getCurrentEntityClass();
    Field field = context.getCurrentField();
    boolean timeUUID = isTimeUUID(context, field);

    validator.validateMapGenerics(field, entityClass);

    Pair<Class<K>, Class<V>> types = determineMapGenericTypes(field);
    Class<K> keyClass = types.left;
    Class<V> valueClass = types.right;

    Method[] accessors = entityIntrospector.findAccessors(entityClass, field);
    PropertyType type = MAP;

    PropertyMeta mapMeta =
        factory()
            .objectMapper(context.getCurrentObjectMapper())
            .type(type)
            .propertyName(context.getCurrentPropertyName())
            .entityClassName(context.getCurrentEntityClass().getCanonicalName())
            .consistencyLevels(context.getCurrentConsistencyLevels())
            .accessors(accessors)
            .field(field)
            .timeuuid(timeUUID)
            .build(keyClass, valueClass);

    log.trace(
        "Built map property meta for property {} of entity class {} : {}",
        mapMeta.getPropertyName(),
        context.getCurrentEntityClass().getCanonicalName(),
        mapMeta);

    return mapMeta;
  }