当前位置: 首页>>代码示例>>Java>>正文


Java Fields类代码示例

本文整理汇总了Java中com.redhat.lightblue.metadata.Fields的典型用法代码示例。如果您正苦于以下问题:Java Fields类的具体用法?Java Fields怎么用?Java Fields使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Fields类属于com.redhat.lightblue.metadata包,在下文中一共展示了Fields类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: shouldGenerateArrayFieldTypesForSimpleArrayElements

import com.redhat.lightblue.metadata.Fields; //导入依赖的package包/类
@Test
public void shouldGenerateArrayFieldTypesForSimpleArrayElements() {
  class HasArray {
    public List<String> getFoobars() {
      return Arrays.asList("foo", "bars");
    }

    public void setFoobars(List<String> foobars) {

    }
  }

  EntitySchema expectedSchema = new EntitySchema("hasArray");
  ArrayField expectedArrayField = new ArrayField("foobars", new SimpleArrayElement(StringType.TYPE));
  Fields expectedFields = expectedSchema.getFields();
  expectedFields.addNew(expectedArrayField);

  EntitySchema schema = generator.generateSchema(HasArray.class);

  assertThat(schema.getFields(), equalToFields(expectedFields));
}
 
开发者ID:lightblue-platform,项目名称:lightblue-java-generator,代码行数:22,代码来源:MetadataGeneratorTest.java

示例2: matchesSafely

import com.redhat.lightblue.metadata.Fields; //导入依赖的package包/类
@Override
protected boolean matchesSafely(Fields item, Description mismatchDescription) {
  boolean matches = true;

  List<Matcher<? super Field>> matchingAllFields = Arrays
      .stream(Iterables.toArray(fields::getFields, Field.class))
      .map(EqualToField::new)
      .collect(Collectors.toList());

  Matcher matcher = Matchers.containsInAnyOrder(matchingAllFields);
  if (!matcher.matches((Iterable) item::getFields)) {
    matches = false;
    matcher.describeMismatch(item, mismatchDescription);
  }

  return matches;
}
 
开发者ID:lightblue-platform,项目名称:lightblue-java-generator,代码行数:18,代码来源:EqualToFields.java

示例3: addFieldToParent

import com.redhat.lightblue.metadata.Fields; //导入依赖的package包/类
/**
 * Adds the <code>newField</cod> to the <code>newFieldPath</code>.
 * @param md - {@link EntityMetadata}
 * @param newFieldPath - {@link Path} to add
 * @param newField - {@link Field} to add at the <code>newFieldPath</code>
 */
private void addFieldToParent(EntityMetadata md, Path newFieldPath, Field newField){
    Fields fields;

    if(newFieldPath.numSegments() == 1){
        fields = md.getFields();
    }
    else{
        Path parentPath = newFieldPath.prefix(-1);
        FieldTreeNode parent = md.resolve(parentPath);

        if(parent instanceof ObjectField){
            fields = ((ObjectField) parent).getFields();
        }
        else if (parent instanceof ObjectArrayElement){
            fields = ((ObjectArrayElement) parent).getFields();
        }
        else {
            throw Error.get(MetadataConstants.ERR_FIELD_WRONG_TYPE, parentPath.toString());
        }
    }
    fields.addNew(newField);
}
 
开发者ID:lightblue-platform,项目名称:lightblue-ldap,代码行数:29,代码来源:LdapMetadataListener.java

示例4: testBeforeCreateNewSchema_alreadyHasDefinedDnAndObjectClass

import com.redhat.lightblue.metadata.Fields; //导入依赖的package包/类
/**
 * The fields that were defined should remain.
 */
@Test
public void testBeforeCreateNewSchema_alreadyHasDefinedDnAndObjectClass(){
    EntityMetadata md = new EntityMetadata("fake");
    setupEntityMetadata(md);
    Fields fields = md.getEntitySchema().getFields();

    SimpleField dnField = new SimpleField(LdapConstant.ATTRIBUTE_DN, StringType.TYPE);
    fields.addNew(dnField);
    ArrayField objectClassField = new ArrayField(LdapConstant.ATTRIBUTE_OBJECT_CLASS, new SimpleArrayElement(StringType.TYPE));
    fields.addNew(objectClassField);
    SimpleField objectClassCountField = new SimpleField(LdapConstant.ATTRIBUTE_OBJECT_CLASS + "#", IntegerType.TYPE);
    fields.addNew(objectClassCountField);

    LdapMetadataListener listener = new LdapMetadataListener();
    listener.beforeCreateNewSchema(null, md);

    assertTrue(md.getFields().has(LdapConstant.ATTRIBUTE_DN));
    assertTrue(md.getFields().has(LdapConstant.ATTRIBUTE_OBJECT_CLASS));
    assertTrue(md.getFields().has(LdapConstant.ATTRIBUTE_OBJECT_CLASS + "#"));

    assertEquals(dnField, md.getFields().getField(LdapConstant.ATTRIBUTE_DN));
    assertEquals(objectClassField, md.getFields().getField(LdapConstant.ATTRIBUTE_OBJECT_CLASS));
    assertEquals(objectClassCountField, md.getFields().getField(LdapConstant.ATTRIBUTE_OBJECT_CLASS + "#"));
}
 
开发者ID:lightblue-platform,项目名称:lightblue-ldap,代码行数:28,代码来源:LdapMetadataListenerTest.java

示例5: translateToObjectNode

import com.redhat.lightblue.metadata.Fields; //导入依赖的package包/类
@Override
ObjectNode translateToObjectNode(Object value, FieldCursor cursor) {
    FieldTreeNode field = cursor.getCurrentNode();

    //Store the current fields so that they can be put back after this operation is complete.
    Fields storeFieldsUntilLater = currentFields;
    if (field instanceof ObjectField) {
        currentFields = ((ObjectField) field).getFields();
    }
    else if (field instanceof ObjectArrayElement) {
        currentFields = ((ObjectArrayElement) field).getFields();
    }
    else {
        throw new IllegalArgumentException("Only Object Field/Element types are supported: " + field.getClass());
    }

    ObjectNode node = super.translateToObjectNode(value, cursor);

    currentFields = storeFieldsUntilLater;

    return node;
}
 
开发者ID:lightblue-platform,项目名称:lightblue-core,代码行数:23,代码来源:NonPersistedPredefinedFieldTranslatorToJson.java

示例6: translate

import com.redhat.lightblue.metadata.Fields; //导入依赖的package包/类
@Override
protected void translate(JsonNodeCursor cursor, Object target) {
    Path path = cursor.getCurrentPath();
    FieldTreeNode fieldNode = entityMetadata.resolve(path);
    if(fieldNode instanceof Field){
        String fieldName = ((Field) fieldNode).getName();

        Fields fields = entityMetadata.getFields();
        if(fieldNode instanceof ObjectField){
            fields = ((ObjectField) fieldNode).getFields();
        }

        if(PredefinedFields.isPredefinedField(fieldName, fields)){
            /*
             * Indicates the field is auto-generated for lightblue purposes. These fields
             * should not be inserted into the data store.
             */
            return;
        }
    }

    super.translate(cursor, target);
}
 
开发者ID:lightblue-platform,项目名称:lightblue-core,代码行数:24,代码来源:NonPersistedPredefinedFieldTranslatorFromJson.java

示例7: addFieldsFromBeanMirror

import com.redhat.lightblue.metadata.Fields; //导入依赖的package包/类
private void addFieldsFromBeanMirror(BeanMirror beanMirror, Fields fields,
    Optional<Fields> maybeOriginal) {
  for (FieldMirror fieldMirror : beanMirror.getFields()) {
    String name = fieldMirror.name();
    Optional<Field> maybeOriginalField = maybeOriginal.map(o -> o.getField(name));

    Field field = getFieldFromFieldMirror(fieldMirror, maybeOriginalField);
    field.setConstraints(getConstraintsForBeanField(fieldMirror));
    fieldMirror.description().ifPresent(field::setDescription);

    if (field instanceof SimpleField) {
      SimpleField simpleField = (SimpleField) field;
      getValueGeneratorForBeanField(fieldMirror).ifPresent(simpleField::setValueGenerator);
    }

    maybeOriginalField.ifPresent(original -> {
      FieldAccess access = field.getAccess();
      FieldAccess originalAccess = original.getAccess();

      access.getFind().setRoles(originalAccess.getFind());
      access.getInsert().setRoles(originalAccess.getInsert());
      access.getUpdate().setRoles(originalAccess.getUpdate());
    });

    fields.addNew(field);
  }
}
 
开发者ID:lightblue-platform,项目名称:lightblue-java-generator,代码行数:28,代码来源:MetadataGenerator.java

示例8: shouldGenerateObjectFieldTypes

import com.redhat.lightblue.metadata.Fields; //导入依赖的package包/类
@Test
public void shouldGenerateObjectFieldTypes() {
  class HasInnerObject {
    public InnerObject getInnerObject() {
      return new InnerObject();
    }

    public void setInnerObject(InnerObject innerObject) {

    }

    class InnerObject {
      public String getFoo() {
        return "foo";
      }

      public void setFoo(String foo) {
      }
    }
  }

  EntitySchema expectedSchema = new EntitySchema("hasInnerObject");
  Fields expectedFields = expectedSchema.getFields();
  ObjectField expectedObjectField = new ObjectField("innerObject");
  expectedObjectField.getFields().addNew(new SimpleField("foo", StringType.TYPE));
  expectedFields.addNew(expectedObjectField);

  EntitySchema schema = generator.generateSchema(HasInnerObject.class);

  assertThat(schema.getFields(), equalToFields(expectedFields));
}
 
开发者ID:lightblue-platform,项目名称:lightblue-java-generator,代码行数:32,代码来源:MetadataGeneratorTest.java

示例9: shouldGenerateArrayFieldTypesForObjectArrayElements

import com.redhat.lightblue.metadata.Fields; //导入依赖的package包/类
@Test
public void shouldGenerateArrayFieldTypesForObjectArrayElements() {
  class HasObjectArray {
    public List<SomeObject> getSomeObjects() {
      return Arrays.asList(new SomeObject(), new SomeObject());
    }

    public void setSomeObjects(List<SomeObject> someObjects) {

    }

    class SomeObject {
      public Integer getSomeNumber() {
        return 42;
      }

      public void setSomeNumber(Integer someNumber) {

      }
    }
  }

  EntitySchema expectedSchema = new EntitySchema("hasObjectArray");
  ObjectArrayElement expectedArrayElement = new ObjectArrayElement();
  expectedArrayElement.getFields().addNew(new SimpleField("someNumber", IntegerType.TYPE));
  ArrayField expectedArrayField = new ArrayField("someObjects", expectedArrayElement);
  Fields expectedFields = expectedSchema.getFields();
  expectedFields.addNew(expectedArrayField);

  EntitySchema schema = generator.generateSchema(HasObjectArray.class);

  assertThat(schema.getFields(), equalToFields(expectedFields));
}
 
开发者ID:lightblue-platform,项目名称:lightblue-java-generator,代码行数:34,代码来源:MetadataGeneratorTest.java

示例10: testBeforeCreateNewSchema_alreadyHasDefinedDn_butAsWrongType

import com.redhat.lightblue.metadata.Fields; //导入依赖的package包/类
@Test(expected = Error.class)
public void testBeforeCreateNewSchema_alreadyHasDefinedDn_butAsWrongType(){
    EntityMetadata md = new EntityMetadata("fake");
    setupEntityMetadata(md);
    Fields fields = md.getEntitySchema().getFields();

    fields.addNew(new SimpleField(LdapConstant.ATTRIBUTE_DN, IntegerType.TYPE));

    new LdapMetadataListener().beforeCreateNewSchema(null, md);
}
 
开发者ID:lightblue-platform,项目名称:lightblue-ldap,代码行数:11,代码来源:LdapMetadataListenerTest.java

示例11: testBeforeCreateNewSchema_alreadyHasDefinedDn_butAsWrongField

import com.redhat.lightblue.metadata.Fields; //导入依赖的package包/类
@Test(expected = Error.class)
public void testBeforeCreateNewSchema_alreadyHasDefinedDn_butAsWrongField(){
    EntityMetadata md = new EntityMetadata("fake");
    setupEntityMetadata(md);
    Fields fields = md.getEntitySchema().getFields();

    fields.addNew(new ArrayField(LdapConstant.ATTRIBUTE_DN));

    new LdapMetadataListener().beforeCreateNewSchema(null, md);
}
 
开发者ID:lightblue-platform,项目名称:lightblue-ldap,代码行数:11,代码来源:LdapMetadataListenerTest.java

示例12: testBeforeCreateNewSchema_alreadyHasDefinedObjectClass_butAsWrongType

import com.redhat.lightblue.metadata.Fields; //导入依赖的package包/类
@Test(expected = Error.class)
public void testBeforeCreateNewSchema_alreadyHasDefinedObjectClass_butAsWrongType(){
    EntityMetadata md = new EntityMetadata("fake");
    setupEntityMetadata(md);
    Fields fields = md.getEntitySchema().getFields();

    fields.addNew(new SimpleField(LdapConstant.ATTRIBUTE_OBJECT_CLASS, StringType.TYPE));

    new LdapMetadataListener().beforeCreateNewSchema(null, md);
}
 
开发者ID:lightblue-platform,项目名称:lightblue-ldap,代码行数:11,代码来源:LdapMetadataListenerTest.java

示例13: testBeforeCreateNewSchema_alreadyHasDefinedObjectClass_butAsWrongField

import com.redhat.lightblue.metadata.Fields; //导入依赖的package包/类
@Test(expected = Error.class)
public void testBeforeCreateNewSchema_alreadyHasDefinedObjectClass_butAsWrongField(){
    EntityMetadata md = new EntityMetadata("fake");
    setupEntityMetadata(md);
    Fields fields = md.getEntitySchema().getFields();

    fields.addNew(new SimpleField(LdapConstant.ATTRIBUTE_OBJECT_CLASS));

    new LdapMetadataListener().beforeCreateNewSchema(null, md);
}
 
开发者ID:lightblue-platform,项目名称:lightblue-ldap,代码行数:11,代码来源:LdapMetadataListenerTest.java

示例14: testBeforeCreateNewSchema_alreadyHasDefinedObjectClass_butWithWrongElementType

import com.redhat.lightblue.metadata.Fields; //导入依赖的package包/类
@Test(expected = Error.class)
public void testBeforeCreateNewSchema_alreadyHasDefinedObjectClass_butWithWrongElementType(){
    EntityMetadata md = new EntityMetadata("fake");
    setupEntityMetadata(md);
    Fields fields = md.getEntitySchema().getFields();

    fields.addNew(new ArrayField(LdapConstant.ATTRIBUTE_OBJECT_CLASS, new SimpleArrayElement(IntegerType.TYPE)));

    new LdapMetadataListener().beforeCreateNewSchema(null, md);
}
 
开发者ID:lightblue-platform,项目名称:lightblue-ldap,代码行数:11,代码来源:LdapMetadataListenerTest.java

示例15: testBeforeCreateNewSchema_alreadyHasDefinedObjectClass_butWithWrongElementField

import com.redhat.lightblue.metadata.Fields; //导入依赖的package包/类
@Test(expected = Error.class)
public void testBeforeCreateNewSchema_alreadyHasDefinedObjectClass_butWithWrongElementField(){
    EntityMetadata md = new EntityMetadata("fake");
    setupEntityMetadata(md);
    Fields fields = md.getEntitySchema().getFields();

    ArrayField field = new ArrayField(LdapConstant.ATTRIBUTE_OBJECT_CLASS, new ObjectArrayElement());
    fields.addNew(field);

    new LdapMetadataListener().beforeCreateNewSchema(null, md);
}
 
开发者ID:lightblue-platform,项目名称:lightblue-ldap,代码行数:12,代码来源:LdapMetadataListenerTest.java


注:本文中的com.redhat.lightblue.metadata.Fields类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。