org.apache.avro.reflect.Nullable Java Examples

The following examples show how to use org.apache.avro.reflect.Nullable. 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 File: BrooklinEnvelope.java    From brooklin with 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 File: AvroFactory.java    From Flink-CEPplus with 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 File: AvroFactory.java    From flink with 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 File: BrooklinEnvelope.java    From brooklin with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Nullable
@Deprecated
public Object getKey() {
  return _key;
}
 
Example #5
Source File: BrooklinEnvelope.java    From brooklin with 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 File: BrooklinEnvelope.java    From brooklin with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Nullable
@Deprecated
public Object getValue() {
  return _value;
}
 
Example #7
Source File: BrooklinEnvelope.java    From brooklin with 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 File: AvroFactory.java    From flink with 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 File: AvroFactory.java    From Flink-CEPplus with 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 File: AvroFactory.java    From flink with 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 File: AvroFactory.java    From flink with 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));
}