/** * Identifies the module class and a list of service ids within the module. */ @Override public String toString() { return String.format("ModuleDef[%s %s]", moduleClass.getName(), InternalUtils.joinSorted(serviceDefs.keySet())); }
/** * Identifies the module class and a list of service ids within the module. */ @Override public String toString() { return String.format("ModuleDef[%s %s]", moduleClass.getName(), InternalUtils.joinSorted(serviceDefs.keySet())); }
public ApplicationStatePersistenceStrategy get(String name) { ApplicationStatePersistenceStrategy result = configuration.get(name); if (result == null) throw new RuntimeException(String.format("No application state persistence strategy is available with name '%s'. Available strategies: %s.", name, InternalUtils .joinSorted(configuration.keySet()))); return result; } }
static String findCommonPackageNameForFolder(String folder, List<String> packageNames) { String packageName = findCommonPackageName(packageNames); if (packageName == null) throw new RuntimeException( String.format( "Package names for library folder '%s' (%s) can not be reduced to a common base package (of at least one term).", folder, InternalUtils.joinSorted(packageNames))); return packageName; }
static <V> String missingValue(V value, Collection<V> values) { return MESSAGES.format("missing-value", value, InternalUtils.joinSorted(values)); } }
static String missingRenderVariable(String componentId, String name, Collection<String> names) { return MESSAGES.format("missing-render-variable", componentId, name, InternalUtils.joinSorted(names)); }
private static String toJavaClassNames(List<Class> classes) { Class[] asArray = classes.toArray(new Class[classes.size()]); String[] namesArray = PlasticUtils.toTypeNames(asArray); List<String> names = CollectionFactory.newList(namesArray); return InternalUtils.joinSorted(names); }
private static String toJavaClassNames(List<Class> classes) { Class[] asArray = classes.toArray(new Class[classes.size()]); String[] namesArray = PlasticUtils.toTypeNames(asArray); List<String> names = CollectionFactory.newList(namesArray); return InternalUtils.joinSorted(names); }
public HibernateSessionSourceImpl(Logger logger, List<HibernateConfigurer> hibernateConfigurers) { long startTime = System.currentTimeMillis(); configuration = new Configuration(); for (HibernateConfigurer configurer : hibernateConfigurers) configurer.configure(configuration); long configurationComplete = System.currentTimeMillis(); sessionFactory = configuration.buildSessionFactory(); long factoryCreated = System.currentTimeMillis(); logger.info(String.format("Hibernate startup: %,d ms to configure, %,d ms overall.", configurationComplete - startTime, factoryCreated - startTime)); logger.info(String.format("Configured Hibernate entities: %s", InternalUtils.joinSorted(sessionFactory.getAllClassMetadata().keySet()))); }
public HibernateSessionSourceImpl(Logger logger, List<HibernateConfigurer> hibernateConfigurers) { long startTime = System.currentTimeMillis(); configuration = new Configuration(); for (HibernateConfigurer configurer : hibernateConfigurers) configurer.configure(configuration); long configurationComplete = System.currentTimeMillis(); sessionFactory = configuration.buildSessionFactory(); long factoryCreated = System.currentTimeMillis(); logger.info(String.format("Hibernate startup: %,d ms to configure, %,d ms overall.", configurationComplete - startTime, factoryCreated - startTime)); logger.info(String.format("Configured Hibernate entities: %s", InternalUtils.joinSorted(sessionFactory.getAllClassMetadata().keySet()))); }
public Translator getByType(Class valueType) { Translator result = registry.get(valueType); if (result == null) { List<String> names = CollectionFactory.newList(); for (Class type : registry.getTypes()) { names.add(type.getName()); } throw new IllegalArgumentException(String.format("No translator is defined for type %s. Registered types: %s.", PlasticUtils.toTypeName(valueType), InternalUtils .joinSorted(names))); } return result; }
private void validate(String category, Map<String, Set<String>> map) { boolean header = false; for (String name : F.flow(map.keySet()).sort()) { Set<String> classNames = map.get(name); if (classNames.size() == 1) { continue; } if (!header) { logger.error(String.format("Some %s(s) map to more than one Java class.", category)); header = true; invalid = true; } logger.error(String.format("%s '%s' maps to %s", InternalUtils.capitalize(category), name, InternalUtils.joinSorted(classNames))); } } }
private ParameterBinder createParameterBinderFromQualifiedParameterName(String qualifiedParameterName, String mixinId, String parameterName) { if (mixinId.equalsIgnoreCase(componentPsuedoMixinId)) { return createParameterBinderForComponent(qualifiedParameterName, parameterName); } if (!mixinIdToInstantiator.containsKey(mixinId)) { throw new TapestryException( String.format("Mixin id for parameter '%s' not found. Attached mixins: %s.", qualifiedParameterName, InternalUtils.joinSorted(mixinIdToInstantiator.keySet())), location, null); } ParameterBinder binder = parameterNameToBinder.get(qualifiedParameterName); if (binder != null) { return binder; } // Ok, so perhaps this is a qualified name for an informal parameter of the mixin. Instantiator instantiator = mixinIdToInstantiator.get(mixinId); assert instantiator != null; return bindInformalParameter(qualifiedParameterName, mixinId, parameterName, instantiator.getModel()); }
static String manyServicesMatchMarker(Class objectType, List<Class> markers, Collection<ServiceDef2> matchingServices) { return MESSAGES.format("many-services-match-marker", PlasticUtils.toTypeName(objectType), toJavaClassNames(markers), InternalUtils.joinSorted(matchingServices)); }
static String manyServicesMatchMarker(Class objectType, List<Class> markers, Collection<ServiceDef2> matchingServices) { return MESSAGES.format("many-services-match-marker", PlasticUtils.toTypeName(objectType), toJavaClassNames(markers), InternalUtils.joinSorted(matchingServices)); }
public void validateEmbeddedIds(Map<String, Location> componentIds, Resource templateResource) { Map<String, Boolean> embeddedIds = CollectionFactory.newCaseInsensitiveMap(); for (String id : getModel().getEmbeddedComponentIds()) embeddedIds.put(id, true); for (String id : componentIds.keySet()) { allocator.allocateId(id); embeddedIds.remove(id); } if (!embeddedIds.isEmpty()) { String className = getModel().getComponentClassName(); throw new RuntimeException(String.format("Embedded component(s) %s are defined within component class %s (or a super-class of %s), but are not present in the component template (%s).", InternalUtils.joinSorted(embeddedIds.keySet()), className, InternalUtils.lastTerm(className), templateResource)); } }
static String missingParameters(List<String> parameters, ComponentPageElement element) { return MESSAGES.format("missing-parameters", InternalUtils.joinSorted(parameters), element .getComponentResources().getComponentModel().getComponentClassName()); }
private String allocateClientId() { if (clientId == null) { return javaScriptSupport.allocateClientId(resources); } if (ensureClientIdUnique) { return javaScriptSupport.allocateClientId(clientId); } else { // See https://issues.apache.org/jira/browse/TAP5-1632 // Basically, on the client, there can be a convenience lookup inside a HTMLFormElement // by id OR name; so an id of "submit" (for example) will mask the HTMLFormElement.submit() // function. if (formControlNameManager.isReserved(clientId)) { throw new TapestryException(String.format( "The value '%s' for parameter clientId is not allowed as it causes a naming conflict in the client-side DOM. " + "Select an id not in the list: %s.", clientId, InternalUtils.joinSorted(formControlNameManager.getReservedNames())), this, null); } } return clientId; }
private String identifyParameterName(ComponentResources resources, String firstGuess, String... otherGuesses) { ComponentModel model = resources.getContainerResources().getComponentModel(); List<String> guesses = CollectionFactory.newList(); guesses.add(firstGuess); for (String name : otherGuesses) { guesses.add(name); } for (String name : guesses) { if (model.isFormalParameter(name)) return name; if (isPublishedParameter(model, name)) return name; } String message = String.format("Containing component %s does not contain a formal parameter or a published parameter %s %s.", model.getComponentClassName(), guesses.size() == 1 ? "matching" : "matching any of", InternalUtils.joinSorted(guesses)); List<String> formalAndPublishedParameters = CollectionFactory.newList(model.getParameterNames()); formalAndPublishedParameters.addAll(getPublishedParameters(model)); throw new UnknownValueException(message, new AvailableValues("Formal and published parameters", formalAndPublishedParameters)); }
public void onRecomputeTotals() { totals = new PageCatalogTotals(); Flow<Page> pages = F.flow(getPages()); totals.loadedPages = pages.count(); totals.definedPages = getPageNames().size(); totals.uniquePageNames = pages.map(new Mapper<Page, String>() { public String map(Page element) { return element.getName(); } }).toSet().size(); totals.components = pages.reduce(new Reducer<Integer, Page>() { public Integer reduce(Integer accumulator, Page element) { return accumulator + element.getStats().componentCount; } }, 0); Set<String> selectorIds = pages.map(new Mapper<Page, String>() { public String map(Page element) { return element.getSelector().toShortString(); } }).toSet(); totals.selectors = InternalUtils.joinSorted(selectorIds); }