public final ConfigurationModule build() throws ClassHierarchyException { final ConfigurationModuleBuilder c = deepCopy(); if (!(c.reqUsed.containsAll(c.reqDecl) && c.optUsed.containsAll(c.optDecl))) { final Set<Field> fset = new MonotonicHashSet<>(); for (final Field f : c.reqDecl) { if (!c.reqUsed.contains(f)) { fset.add(f); } } for (final Field f : c.optDecl) { if (!c.optUsed.contains(f)) { fset.add(f); } } throw new ClassHierarchyException( "Found declared options that were not used in binds: " + toString(fset)); } for (final Class<?> clz : c.lateBindClazz.keySet()) { try { c.b.bind(ReflectionUtilities.getFullName(clz), c.lateBindClazz.get(clz)); } catch (final NameResolutionException e) { throw new ClassHierarchyException("ConfigurationModule refers to unknown class: " + c.lateBindClazz.get(clz), e); } catch (final BindException e) { throw new ClassHierarchyException("bind failed while initializing ConfigurationModuleBuilder", e); } } return new ConfigurationModule(c); }