Package org.springframework.data.mongodb.core.aggregation.ExposedFields

Examples of org.springframework.data.mongodb.core.aggregation.ExposedFields.ExposedField


    Assert.notNull(fields, "Fields must not be null!");
    List<ExposedField> result = new ArrayList<ExposedField>();

    for (Field field : fields) {
      result.add(new ExposedField(field, synthetic));
    }

    return ExposedFields.from(result);
  }
View Full Code Here


      if (!(obj instanceof ExposedField)) {
        return false;
      }

      ExposedField that = (ExposedField) obj;

      return this.field.equals(that.field) && this.synthetic == that.synthetic;
    }
View Full Code Here

   * @param field must not be {@literal null}.
   */
  public UnwindOperation(Field field) {

    Assert.notNull(field);
    this.field = new ExposedField(field, true);
  }
View Full Code Here

   */
  private FieldReference getReference(Field field, String name) {

    Assert.notNull(name, "Name must not be null!");

    ExposedField exposedField = exposedFields.getField(name);

    if (exposedField != null) {

      if (field != null) {
        // we return a FieldReference to the given field directly to make sure that we reference the proper alias here.
        return new FieldReference(new ExposedField(field, exposedField.isSynthetic()));
      }

      return new FieldReference(exposedField);
    }

    if (name.contains(".")) {

      // for nested field references we only check that the root field exists.
      ExposedField rootField = exposedFields.getField(name.split("\\.")[0]);

      if (rootField != null) {

        // We have to synthetic to true, in order to render the field-name as is.
        return new FieldReference(new ExposedField(name, true));
      }
    }

    throw new IllegalArgumentException(String.format("Invalid reference '%s'!", name));
  }
View Full Code Here

     * (non-Javadoc)
     * @see org.springframework.data.mongodb.core.aggregation.AggregationOperationContext#getReference(org.springframework.data.mongodb.core.aggregation.ExposedFields.AvailableField)
     */
    @Override
    public FieldReference getReference(Field field) {
      return new FieldReference(new ExposedField(field, true));
    }
View Full Code Here

     * (non-Javadoc)
     * @see org.springframework.data.mongodb.core.aggregation.AggregationOperationContext#getReference(java.lang.String)
     */
    @Override
    public FieldReference getReference(String name) {
      return new FieldReference(new ExposedField(new AggregationField(name), true));
    }
View Full Code Here

    PersistentPropertyPath<MongoPersistentProperty> propertyPath = mappingContext.getPersistentPropertyPath(
        field.getTarget(), type);
    Field mappedField = field(propertyPath.getLeafProperty().getName(),
        propertyPath.toDotPath(MongoPersistentProperty.PropertyToFieldNameConverter.INSTANCE));

    return new FieldReference(new ExposedField(mappedField, true));
  }
View Full Code Here

  public ExposedFields getFields() {

    ExposedFields fields = null;

    for (Projection projection : projections) {
      ExposedField field = projection.getExposedField();
      fields = fields == null ? ExposedFields.from(field) : fields.and(field);
    }

    return fields;
  }
View Full Code Here

     * @param field must not be {@literal null}.
     */
    public Projection(Field field) {

      Assert.notNull(field, "Field must not be null!");
      this.field = new ExposedField(field, true);
    }
View Full Code Here

   * @see org.springframework.data.mongodb.core.aggregation.AggregationOperationContext#getFields()
   */
  @Override
  public ExposedFields getFields() {

    ExposedFields fields = this.idFields.and(new ExposedField(Fields.UNDERSCORE_ID, true));

    for (Operation operation : operations) {
      fields = fields.and(operation.asField());
    }

View Full Code Here

TOP

Related Classes of org.springframework.data.mongodb.core.aggregation.ExposedFields.ExposedField

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.