private void checkPortableAttributes(FieldDefinition fd, Portable portable) { if (fd.getFactoryId() != portable.getFactoryId()) { throw new HazelcastSerializationException("Wrong Portable type! Generic portable types are not supported! " + " Expected factory-id: " + fd.getFactoryId() + ", Actual factory-id: " + portable.getFactoryId()); } if (fd.getClassId() != portable.getClassId()) { throw new HazelcastSerializationException("Wrong Portable type! Generic portable types are not supported! " + "Expected class-id: " + fd.getClassId() + ", Actual class-id: " + portable.getClassId()); } }
@Override public void writePortable(PortableWriter out) throws IOException { out.writeUTF("name", name); out.writePortableArray("limbs", limbs); }
@Override public void readPortable(PortableReader in) throws IOException { name = in.readUTF("name"); } }
/** * @param cd given classDefinition to validate against * @param fd given fieldDefinition to validate against * @param fullPath full path - just for output * @throws IllegalArgumentException if the current field definition is not of an array type */ static void validateArrayType(ClassDefinition cd, FieldDefinition fd, String fullPath) { if (!fd.getType().isArrayType()) { throw new IllegalArgumentException("Wrong use of array operator: '" + fullPath + "' for ClassDefinition {id: " + cd.getClassId() + ", version: " + cd.getVersion() + "}"); } }
public FieldType getSingleType() { if (isArrayType()) { // GOTCHA: Wont' work if you add more types!!! return get((byte) (getId() % TYPES_COUNT)); } return this; }
@SerializableByConvention private class ObjectToData implements IFunction<Object, Data> { @Override public Data apply(Object input) { SerializationService ss = mapStoreContext.getSerializationService(); return ss.toData(input, partitioningStrategy); } } }
private void check() { if (done) { throw new HazelcastSerializationException("ClassDefinition is already built for " + classId); } }
/** * @return true if managed to setup the context and the path was a single token path indeed, false otherwise */ boolean trySetupContextForSingleTokenPath(String path) { fd = cd.getField(path); return fd != null; }
/** * Merges cache entries from source to destination directly unless the merging entry is {@code null}. */ @BinaryInterface public class PassThroughCacheMergePolicy implements StorageTypeAwareCacheMergePolicy { public PassThroughCacheMergePolicy() { } @Override public Object merge(String cacheName, CacheEntryView mergingEntry, CacheEntryView existingEntry) { return mergingEntry != null ? mergingEntry.getValue() : existingEntry.getValue(); } }
private void checkPortableAttributes(FieldDefinition fd, Portable portable) { if (fd.getFactoryId() != portable.getFactoryId()) { throw new HazelcastSerializationException("Wrong Portable type! Generic portable types are not supported! " + " Expected factory-id: " + fd.getFactoryId() + ", Actual factory-id: " + portable.getFactoryId()); } if (fd.getClassId() != portable.getClassId()) { throw new HazelcastSerializationException("Wrong Portable type! Generic portable types are not supported! " + "Expected class-id: " + fd.getClassId() + ", Actual class-id: " + portable.getClassId()); } }
/** * @param cd given classDefinition to validate against * @param fd given fieldDefinition to validate against * @param fullPath full path - just for output * @throws IllegalArgumentException if the current field definition is not of an array type */ static void validateArrayType(ClassDefinition cd, FieldDefinition fd, String fullPath) { if (!fd.getType().isArrayType()) { throw new IllegalArgumentException("Wrong use of array operator: '" + fullPath + "' for ClassDefinition {id: " + cd.getClassId() + ", version: " + cd.getVersion() + "}"); } }
public FieldType getSingleType() { if (isArrayType()) { // GOTCHA: Wont' work if you add more types!!! return get((byte) (getId() % TYPES_COUNT)); } return this; }
@SerializableByConvention private static class TrueFilter implements IFunction<EventRegistration, Boolean> { @Override public Boolean apply(EventRegistration eventRegistration) { return TRUE; } } }
/** * @return true if managed to setup the context and the path was a single token path indeed, false otherwise */ boolean trySetupContextForSingleTokenPath(String path) { fd = cd.getField(path); return fd != null; }
/** * {@link com.hazelcast.config.EvictionPolicy#RANDOM} policy based {@link EvictionPolicyComparator}. */ @SerializableByConvention public class RandomEvictionPolicyComparator extends EvictionPolicyComparator { @Override @SuppressWarnings("ComparatorMethodParameterNotUsed") public int compare(EvictableEntryView e1, EvictableEntryView e2) { return 0; } }
/** * {@link com.hazelcast.config.EvictionPolicy#RANDOM} policy based {@link EvictionPolicyComparator}. */ @SerializableByConvention public class RandomEvictionPolicyComparator extends EvictionPolicyComparator { @Override @SuppressWarnings("ComparatorMethodParameterNotUsed") public int compare(EvictableEntryView e1, EvictableEntryView e2) { return 0; } }
/** * Filters out listeners other than invalidation related ones. */ @SerializableByConvention private static class InvalidationAcceptorFilter implements IFunction<EventRegistration, Boolean> { @Override public Boolean apply(EventRegistration eventRegistration) { EventFilter filter = eventRegistration.getFilter(); return filter instanceof EventListenerFilter && filter.eval(INVALIDATION.getType()); } }