@Override public int size() { return delegate.size(); }
@Override public int size() { return delegate.size(); }
@Override public boolean hasSingleElement(EnumSet<? extends Enum<?>> value) { return value.size() == 1; }
@Override public boolean hasSingleElement(EnumSet<? extends Enum<?>> value) { return value.size() == 1; }
/** * Determine whether the given set is fully populated (or "full"), meaning it contains all possible values. * * @param set the set * * @return {@code true} if the set is full, {@code false} otherwise */ public static boolean isFull(final EnumSet<ScramServerErrorCode> set) { return set != null && set.size() == fullSize; }
/** * Determine whether the given set is fully populated (or "full"), meaning it contains all possible values. * * @param set the set * * @return {@code true} if the set is full, {@code false} otherwise */ public static boolean isFull(final EnumSet<Type> set) { return set != null && set.size() == fullSize; }
@SuppressWarnings("rawtypes") // necessary to compile against Java 8 static ImmutableSet asImmutable(EnumSet set) { switch (set.size()) { case 0: return ImmutableSet.of(); case 1: return ImmutableSet.of(Iterables.getOnlyElement(set)); default: return new ImmutableEnumSet(set); } }
@SuppressWarnings("rawtypes") // necessary to compile against Java 8 static ImmutableSet asImmutable(EnumSet set) { switch (set.size()) { case 0: return ImmutableSet.of(); case 1: return ImmutableSet.of(Iterables.getOnlyElement(set)); default: return new ImmutableEnumSet(set); } }
public byte[] getAnalysisTypesCacheKey() { int size = 1; List<byte[]> typeBytesList = Lists.newArrayListWithExpectedSize(analysisTypes.size()); for (AnalysisType analysisType : analysisTypes) { final byte[] bytes = analysisType.getCacheKey(); typeBytesList.add(bytes); size += bytes.length; } final ByteBuffer bytes = ByteBuffer.allocate(size); bytes.put(ANALYSIS_TYPES_CACHE_PREFIX); for (byte[] typeBytes : typeBytesList) { bytes.put(typeBytes); } return bytes.array(); }
@SuppressWarnings("rawtypes") // necessary to compile against Java 8 static ImmutableSet asImmutable(EnumSet set) { switch (set.size()) { case 0: return ImmutableSet.of(); case 1: return ImmutableSet.of(Iterables.getOnlyElement(set)); default: return new ImmutableEnumSet(set); } }
@Override public void write(DataOutput out) throws IOException { super.write(out); out.writeByte(actions != null ? actions.size() : 0); if (actions != null) { for (Action a: actions) { out.writeByte(a.code()); } } out.writeByte(scope.code()); }
@Override public final void serialize(EnumSet<? extends Enum<?>> value, JsonGenerator gen, SerializerProvider provider) throws IOException { final int len = value.size(); if (len == 1) { if (((_unwrapSingle == null) && provider.isEnabled(SerializationFeature.WRITE_SINGLE_ELEM_ARRAYS_UNWRAPPED)) || (_unwrapSingle == Boolean.TRUE)) { serializeContents(value, gen, provider); return; } } gen.writeStartArray(len); serializeContents(value, gen, provider); gen.writeEndArray(); }
@Override public void writeObject(FSTObjectOutput out, Object toWrite, FSTClazzInfo clzInfo, FSTClazzInfo.FSTFieldInfo referencedBy, int streamPosition) throws IOException { EnumSet enset = (EnumSet) toWrite; int count = 0; out.writeInt(enset.size()); if ( enset.isEmpty() ) { //WTF only way to determine enumtype .. EnumSet compl = EnumSet.complementOf(enset); out.writeStringUTF(FSTUtil.getRealEnumClass(compl.iterator().next().getClass()).getName()); } else { for (Object element : enset) { if ( count == 0 ) { out.writeStringUTF(FSTUtil.getRealEnumClass(element.getClass()).getName()); } out.writeStringUTF(element.toString()); count++; } } }
@SuppressWarnings("rawtypes") // necessary to compile against Java 8 static ImmutableSet asImmutable(EnumSet set) { switch (set.size()) { case 0: return ImmutableSet.of(); case 1: return ImmutableSet.of(Iterables.getOnlyElement(set)); default: return new ImmutableEnumSet(set); } }
@Override public void writeObject(FSTObjectOutput out, Object toWrite, FSTClazzInfo clzInfo, FSTClazzInfo.FSTFieldInfo referencedBy, int streamPosition) throws IOException { EnumSet enset = (EnumSet) toWrite; int count = 0; out.writeInt(enset.size()); if ( enset.isEmpty() ) { //WTF only way to determine enumtype .. EnumSet compl = EnumSet.complementOf(enset); out.writeClassTag(FSTUtil.getRealEnumClass(compl.iterator().next().getClass())); } else { for (Object element : enset) { if ( count == 0 ) { out.writeClassTag(FSTUtil.getRealEnumClass(element.getClass())); } out.writeObjectInternal(element, null, Enum.class); count++; } } }
@Override protected Map<String, FieldLoadSaveValidator<?>> createAttributeValidatorsMap() { EnumSet<LogLevel> logLevels = EnumSet.allOf( LogLevel.class ); LogLevel random = (LogLevel) logLevels.toArray()[new Random().nextInt( logLevels.size() )]; return toMap( "loglevel", new EnumLoadSaveValidator<LogLevel>( random ) ); } }
@Override public final void serialize(EnumSet<? extends Enum<?>> value, JsonGenerator gen, SerializerProvider provider) throws IOException { final int len = value.size(); if (len == 1) { if (((_unwrapSingle == null) && provider.isEnabled(SerializationFeature.WRITE_SINGLE_ELEM_ARRAYS_UNWRAPPED)) || (_unwrapSingle == Boolean.TRUE)) { serializeContents(value, gen, provider); return; } } gen.writeStartArray(len); serializeContents(value, gen, provider); gen.writeEndArray(); }
@Override public void encodeRest(final ActiveMQBuffer buffer) { buffer.writeSimpleString(address); buffer.writeInt(routingTypes.size()); for (RoutingType routingType : routingTypes) { buffer.writeByte(routingType.getType()); } buffer.writeBoolean(requiresResponse); buffer.writeBoolean(autoCreated); }
@Test public void testStandardEnumSetWithAutoGrowing() { GenericBean<?> gb = new GenericBean<>(); BeanWrapper bw = new BeanWrapperImpl(gb); bw.setAutoGrowNestedPaths(true); assertNull(gb.getStandardEnumSet()); bw.getPropertyValue("standardEnumSet.class"); assertEquals(0, gb.getStandardEnumSet().size()); }
@Test public void testStandardEnumSetWithMultipleValues() { GenericBean<?> gb = new GenericBean<>(); BeanWrapper bw = new BeanWrapperImpl(gb); bw.setConversionService(new DefaultConversionService()); assertNull(gb.getStandardEnumSet()); bw.setPropertyValue("standardEnumSet", new String[] {"VALUE_1", "VALUE_2"}); assertEquals(2, gb.getStandardEnumSet().size()); assertTrue(gb.getStandardEnumSet().contains(CustomEnum.VALUE_1)); assertTrue(gb.getStandardEnumSet().contains(CustomEnum.VALUE_2)); }