@Override public GenericRecord copy() throws CopyNotSupportedException { if (!(this.record instanceof GenericData.Record)) { throw new CopyNotSupportedException( "The record to make copy is not an instance of " + GenericData.Record.class.getName()); } // Make a deep copy of the original record return new GenericData.Record((GenericData.Record) this.record, true); } }
@Override public GlobalMetadata<S> copy() throws CopyNotSupportedException { if (CopyHelper.isCopyable(schema)) { return new GlobalMetadata((S)CopyHelper.copy(schema)); } throw new CopyNotSupportedException("Type is not copyable: " + schema.getClass().getName()); }
/** * Copy this object if needed. * @param thing : this object that needs to be copied * @return: a possibly copied instance * @throws CopyNotSupportedException if thing needs to be copied but cannot be */ public static Object copy(Object thing) throws CopyNotSupportedException { if (!isCopyable(thing)) { throw new CopyNotSupportedException(thing.getClass().getName() + " cannot be copied. See Copyable"); } if (thing instanceof Copyable) { return ((Copyable) thing).copy(); } // Support for a few primitive types out of the box if (thing instanceof byte[]) { byte[] copy = new byte[((byte[]) thing).length]; System.arraycopy(thing, 0, copy, 0, ((byte[]) thing).length); return copy; } // Assume that everything other type is immutable, not checking this again return thing; }
throw new CopyNotSupportedException(convertedRecord.getClass().getName() + " is not copyable");
throw new CopyNotSupportedException(schema + " is not copyable");
@Override public GenericRecord copy() throws CopyNotSupportedException { if (!(this.record instanceof GenericData.Record)) { throw new CopyNotSupportedException( "The record to make copy is not an instance of " + GenericData.Record.class.getName()); } // Make a deep copy of the original record return new GenericData.Record((GenericData.Record) this.record, true); } }
@Override public GlobalMetadata<S> copy() throws CopyNotSupportedException { if (CopyHelper.isCopyable(schema)) { return new GlobalMetadata((S)CopyHelper.copy(schema)); } throw new CopyNotSupportedException("Type is not copyable: " + schema.getClass().getName()); }
/** * Copy this object if needed. * @param thing : this object that needs to be copied * @return: a possibly copied instance * @throws CopyNotSupportedException if thing needs to be copied but cannot be */ public static Object copy(Object thing) throws CopyNotSupportedException { if (!isCopyable(thing)) { throw new CopyNotSupportedException(thing.getClass().getName() + " cannot be copied. See Copyable"); } if (thing instanceof Copyable) { return ((Copyable) thing).copy(); } // Support for a few primitive types out of the box if (thing instanceof byte[]) { byte[] copy = new byte[((byte[]) thing).length]; System.arraycopy(thing, 0, copy, 0, ((byte[]) thing).length); return copy; } // Assume that everything other type is immutable, not checking this again return thing; }
throw new CopyNotSupportedException(convertedRecord.getClass().getName() + " is not copyable");
throw new CopyNotSupportedException(schema + " is not copyable");