/** * Check preconditions for the type. */ @Value.Check default void checkPreconditions() { final SortedSet<SMFAttributeName> both = this.requiredAttributes().keySet().intersect( this.optionalAttributes().keySet()); Preconditions.checkPrecondition( both, both.isEmpty(), s -> "The intersection of the required and optional attributes must be empty"); } }
/** * Check preconditions for the type. */ @Value.Check default void checkPreconditions() { final SortedSet<SMFAttributeName> both = this.requiredAttributes().keySet().intersect( this.optionalAttributes().keySet()); Preconditions.checkPrecondition( both, both.isEmpty(), s -> "The intersection of the required and optional attributes must be empty"); } }
/** * @return A module resolver */ public static SMFFilterCommandModuleResolverType create() { SortedMap<String, SMFFilterCommandModuleType> modules = TreeMap.empty(); final ServiceLoader<SMFFilterCommandModuleProviderType> providers = ServiceLoader.load(SMFFilterCommandModuleProviderType.class); final Iterator<SMFFilterCommandModuleProviderType> iter = providers.iterator(); while (iter.hasNext()) { final SMFFilterCommandModuleProviderType provider = iter.next(); final SortedMap<String, SMFFilterCommandModuleType> available = provider.available(); for (final String name : available.keySet()) { final SMFFilterCommandModuleType module = available.get(name).get(); if (modules.containsKey(name)) { LOG.warn("multiple modules with the same name: {}", name); } if (LOG.isDebugEnabled()) { LOG.debug("registered module {} via provider {}", name, provider); } modules = modules.put(name, module); } } return new SMFFilterCommandModuleResolver(modules); }
private void failMissedAttributes() { final Set<SMFAttributeName> names = this.header.attributesByName().keySet().diff( this.attributes_attempted.keySet()); if (!names.isEmpty()) { names.forEach( name -> this.fail( "No data specified for attribute: " + name.value(), Optional.empty())); } }
/** * Check preconditions for the type. */ @Value.Check default void checkPreconditions() { HashMap<Integer, SMFByteBufferPackedAttribute> m = HashMap.empty(); final SortedMap<Integer, SMFByteBufferPackedAttribute> by_offset = this.packedAttributesByOffset(); for (final Integer offset : by_offset.keySet()) { Preconditions.checkPreconditionI( offset.intValue(), !m.containsKey(offset), i -> "All attribute offsets must be unique"); m = m.put(offset, by_offset.get(offset).get()); } } }