Java Code Examples for org.apache.avro.reflect.Nullable

The following examples show how to use org.apache.avro.reflect.Nullable. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: brooklin   Source File: BrooklinEnvelope.java    License: BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Construct a BrooklinEnvelope using record key, value, and metadata
 * @param key The record key (e.g. primary key)
 * @param previousValue The old record value
 * @param value The new record value
 * @param metadata Additional metadata to associate with the change event
 */
public BrooklinEnvelope(@Nullable Object key, @Nullable Object value, @Nullable Object previousValue,
    Map<String, String> metadata) {
  Validate.notNull(metadata, "metadata cannot be null");
  setKey(key);
  setValue(value);
  setPreviousValue(previousValue);
  setMetadata(metadata);
}
 
Example 2
Source Project: Flink-CEPplus   Source File: AvroFactory.java    License: Apache License 2.0 4 votes vote down vote up
@Nullable
static Schema parseSchemaString(@Nullable String schemaString) {
	return (schemaString == null) ? null : new Schema.Parser().parse(schemaString);
}
 
Example 3
Source Project: flink   Source File: AvroFactory.java    License: Apache License 2.0 4 votes vote down vote up
@Nullable
static Schema parseSchemaString(@Nullable String schemaString) {
	return (schemaString == null) ? null : new Schema.Parser().parse(schemaString);
}
 
Example 4
Source Project: brooklin   Source File: BrooklinEnvelope.java    License: BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Nullable
@Deprecated
public Object getKey() {
  return _key;
}
 
Example 5
Source Project: brooklin   Source File: BrooklinEnvelope.java    License: BSD 2-Clause "Simplified" License 4 votes vote down vote up
/**
 * Set the record key
 */
public void setKey(@Nullable Object key) {
  _key = key instanceof Optional ? ((Optional<?>) key).orElse(null) : key;
}
 
Example 6
Source Project: brooklin   Source File: BrooklinEnvelope.java    License: BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Nullable
@Deprecated
public Object getValue() {
  return _value;
}
 
Example 7
Source Project: brooklin   Source File: BrooklinEnvelope.java    License: BSD 2-Clause "Simplified" License 4 votes vote down vote up
/**
 * Set the record value
 */
public void setValue(@Nullable Object value) {
  _value = value instanceof Optional ? ((Optional<?>) value).orElse(null) : value;
}
 
Example 8
Source Project: flink   Source File: AvroFactory.java    License: Apache License 2.0 4 votes vote down vote up
@Nullable
static Schema parseSchemaString(@Nullable String schemaString) {
	return (schemaString == null) ? null : new Schema.Parser().parse(schemaString);
}
 
Example 9
Source Project: Flink-CEPplus   Source File: AvroFactory.java    License: Apache License 2.0 3 votes vote down vote up
/**
 * Creates Avro Writer and Reader for a specific type.
 *
 * <p>Given an input type, and possible the current schema, and a previously known schema (also known as writer
 * schema) create will deduce the best way to initalize a reader and writer according to the following rules:
 * <ul>
 * <li>If type is an Avro generated class (an {@link SpecificRecord} then the reader would use the
 * previousSchema for reading (if present) otherwise it would use the schema attached to the auto generated
 * class.
 * <li>If the type is a GenericRecord then the reader and the writer would be created with the supplied
 * (mandatory) schema.
 * <li>Otherwise, we use Avro's reflection based reader and writer that would deduce the schema via reflection.
 * If the previous schema is also present (when restoring a serializer for example) then the reader would be
 * created with both schemas.
 * </ul>
 */
static <T> AvroFactory<T> create(Class<T> type, @Nullable Schema currentSchema, @Nullable Schema previousSchema) {
	final ClassLoader cl = Thread.currentThread().getContextClassLoader();

	if (SpecificRecord.class.isAssignableFrom(type)) {
		return fromSpecific(type, cl, Optional.ofNullable(previousSchema));
	}
	if (GenericRecord.class.isAssignableFrom(type)) {
		return fromGeneric(cl, currentSchema);
	}
	return fromReflective(type, cl, Optional.ofNullable(previousSchema));
}
 
Example 10
Source Project: flink   Source File: AvroFactory.java    License: Apache License 2.0 3 votes vote down vote up
/**
 * Creates Avro Writer and Reader for a specific type.
 *
 * <p>Given an input type, and possible the current schema, and a previously known schema (also known as writer
 * schema) create will deduce the best way to initalize a reader and writer according to the following rules:
 * <ul>
 * <li>If type is an Avro generated class (an {@link SpecificRecord} then the reader would use the
 * previousSchema for reading (if present) otherwise it would use the schema attached to the auto generated
 * class.
 * <li>If the type is a GenericRecord then the reader and the writer would be created with the supplied
 * (mandatory) schema.
 * <li>Otherwise, we use Avro's reflection based reader and writer that would deduce the schema via reflection.
 * If the previous schema is also present (when restoring a serializer for example) then the reader would be
 * created with both schemas.
 * </ul>
 */
static <T> AvroFactory<T> create(Class<T> type, @Nullable Schema currentSchema, @Nullable Schema previousSchema) {
	final ClassLoader cl = Thread.currentThread().getContextClassLoader();

	if (SpecificRecord.class.isAssignableFrom(type)) {
		return fromSpecific(type, cl, Optional.ofNullable(previousSchema));
	}
	if (GenericRecord.class.isAssignableFrom(type)) {
		return fromGeneric(cl, currentSchema);
	}
	return fromReflective(type, cl, Optional.ofNullable(previousSchema));
}
 
Example 11
Source Project: flink   Source File: AvroFactory.java    License: Apache License 2.0 3 votes vote down vote up
/**
 * Creates Avro Writer and Reader for a specific type.
 *
 * <p>Given an input type, and possible the current schema, and a previously known schema (also known as writer
 * schema) create will deduce the best way to initalize a reader and writer according to the following rules:
 * <ul>
 * <li>If type is an Avro generated class (an {@link SpecificRecord} then the reader would use the
 * previousSchema for reading (if present) otherwise it would use the schema attached to the auto generated
 * class.
 * <li>If the type is a GenericRecord then the reader and the writer would be created with the supplied
 * (mandatory) schema.
 * <li>Otherwise, we use Avro's reflection based reader and writer that would deduce the schema via reflection.
 * If the previous schema is also present (when restoring a serializer for example) then the reader would be
 * created with both schemas.
 * </ul>
 */
static <T> AvroFactory<T> create(Class<T> type, @Nullable Schema currentSchema, @Nullable Schema previousSchema) {
	final ClassLoader cl = Thread.currentThread().getContextClassLoader();

	if (SpecificRecord.class.isAssignableFrom(type)) {
		return fromSpecific(type, cl, Optional.ofNullable(previousSchema));
	}
	if (GenericRecord.class.isAssignableFrom(type)) {
		return fromGeneric(cl, currentSchema);
	}
	return fromReflective(type, cl, Optional.ofNullable(previousSchema));
}