Package com.linkedin.data.schema

Examples of com.linkedin.data.schema.EnumDataSchema


  }

  @Test
  public void testEnumSchema()
  {
    final EnumDataSchema schema = (EnumDataSchema) DataTemplateUtil.getSchema(EnumFruits.class);
    final String value = (String) SchemaSampleDataGenerator.buildData(schema, _spec);
    Assert.assertSame(schema.getSymbolDocs().size(), EnumFruits.class.getEnumConstants().length - 1/*The $UNKNOWN value*/);
    EnumFruits.valueOf(value);
  }
View Full Code Here


          }
          result = value;
          break;
        case ENUM:
          String enumValue = (String) value;
          EnumDataSchema enumDataSchema = (EnumDataSchema) dataSchema;
          if (enumDataSchema.getSymbols().contains(enumValue) == false)
          {
            throw new IllegalArgumentException(message(path, "enum value %1$s not one of %2$s", value, enumDataSchema.getSymbols()));
          }
          result = value;
          break;
        case FIXED:
          clazz = value.getClass();
View Full Code Here

          byteBuffer.rewind();
          result = byteString;
          break;
        case ENUM:
          String enumValue = value.toString();
          EnumDataSchema enumDataSchema = (EnumDataSchema) dereferencedDataSchema;
          if (enumDataSchema.getSymbols().contains(enumValue) == false)
          {
            appendMessage("enum value %1$s not one of %2$s", enumValue, enumDataSchema.getSymbols());
            result = BAD_RESULT;
            break;
          }
          result = enumValue;
          break;
View Full Code Here

        case BYTES:
          result = ByteBuffer.wrap(translateBytes(value));
          break;
        case ENUM:
          String enumValue = value.toString();
          EnumDataSchema enumDataSchema = (EnumDataSchema) dereferencedDataSchema;
          if (enumDataSchema.getSymbols().contains(enumValue) == false)
          {
            appendMessage("enum value %1$s not one of %2$s", enumValue, enumDataSchema.getSymbols());
            result = BAD_RESULT;
            break;
          }
          result = _avroAdapter.createEnumSymbol(avroSchema, enumValue);
          break;
View Full Code Here

    return params;
  }

  private List<Parameter<?>> getEnumParams()
  {
    EnumDataSchema simpleEnumSchema = new EnumDataSchema(new Name("com.linkedin.restli.common.test.SimpleEnum"));
    simpleEnumSchema.setSymbols(Arrays.asList(new String[]{"A", "B", "C"}), null);
    List<Parameter<?>> enumParams = new ArrayList<Parameter<?>>();
    enumParams.add(new Parameter<SimpleEnum>(
        "simpleEnum",
        SimpleEnum.class,
        simpleEnumSchema,
View Full Code Here

      DataSchema schema = DataTemplateUtil.getSchema(enumClass);
      assertNotNull(schema);
      assertTrue(schema instanceof EnumDataSchema);

      // get symbols
      EnumDataSchema enumSchema = (EnumDataSchema) schema;
      Set<String> schemaSymbols = new HashSet<String>(enumSchema.getSymbols());
      assertNotNull(schemaSymbols);

      for (String symbol : schemaSymbols)
      {
        // IllegalArgumentException thrown if not valid symbol
View Full Code Here

  private void bindSchemaResolvers()
  {
    StringBuilder errors = new StringBuilder();

    Name toneName = new Name("com.linkedin.greetings.api.Tone");
    EnumDataSchema tone = new EnumDataSchema(toneName);
    List<String> symbols = new ArrayList<String>();
    symbols.add("FRIENDLY");
    symbols.add("SINCERE");
    symbols.add("INSULTING");
    tone.setSymbols(symbols, errors);

    Name greetingName = new Name("com.linkedin.greetings.api.Greeting");
    RecordDataSchema prevGreeting = new RecordDataSchema(greetingName, RecordDataSchema.RecordType.RECORD);
    List<RecordDataSchema.Field> oldFields = new ArrayList<RecordDataSchema.Field>();
    RecordDataSchema.Field id = new RecordDataSchema.Field(new LongDataSchema());
View Full Code Here

TOP

Related Classes of com.linkedin.data.schema.EnumDataSchema

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.