method2testcases
stringlengths
118
3.08k
### Question: OntologyTerms { public static <O extends Ontology<?, ?>> Set<TermId> childrenOf(TermId termId, O ontology) { Set<TermId> result = new HashSet<>(); visitChildrenOf(termId, ontology, new TermVisitor<O>() { @Override public boolean visit(O ontology, TermId termId) { result.add(termId); return true; } }); ret...
### Question: OntologyTerms { public static <O extends Ontology<?, ?>> void visitParentsOf(TermId termId, O ontology, TermVisitor<O> termVisitor) { BreadthFirstSearch<TermId, ImmutableEdge<TermId>> bfs = new BreadthFirstSearch<>(); @SuppressWarnings("unchecked") DirectedGraph<TermId, ImmutableEdge<TermId>> graph = (Dir...
### Question: OntologyTerms { public static <O extends Ontology<?, ?>> Set<TermId> parentsOf(TermId termId, O ontology) { Set<TermId> result = new HashSet<>(); visitParentsOf(termId, ontology, new TermVisitor<O>() { @Override public boolean visit(O ontology, TermId termId) { result.add(termId); return true; } }); retur...
### Question: ObjectScoreDistribution implements Serializable { public double estimatePValue(double score) { Entry<Double, Double> previous = null; for (Entry<Double, Double> entry : cumulativeFrequencies.entrySet()) { if (previous == null && score < entry.getKey()) { return 1.0; } if (previous != null && previous.getK...
### Question: ScoreDistributions { public static ScoreDistribution merge(Collection<ScoreDistribution> distributions) { if (distributions.isEmpty()) { throw new CannotMergeScoreDistributions("Cannot merge zero ScoreDistributions objects."); } if (distributions.stream().map(d -> d.getNumTerms()).collect(Collectors.toSet...
### Question: ScoreSamplingOptions implements Serializable, Cloneable { @Override public String toString() { return "ScoreSamplingOptions [numThreads=" + numThreads + ", minObjectId=" + minObjectId + ", maxObjectId=" + maxObjectId + ", minNumTerms=" + minNumTerms + ", maxNumTerms=" + maxNumTerms + ", numIterations=" + ...
### Question: ImmutableEdge implements Edge<V> { @Override public final Object clone() { return new ImmutableEdge<V>(source, dest, id); } ImmutableEdge(final V source, final V dest, final int id); static ImmutableEdge<V> construct(final V source, final V dest, final int id); @Override final V getSource(); @Overri...
### Question: TermIds { public static Set<TermId> augmentWithAncestors(ImmutableOntology<?, ?> ontology, Set<TermId> termIds, boolean includeRoot) { termIds.addAll(ontology.getAllAncestorTermIds(termIds, includeRoot)); return termIds; } static Set<TermId> augmentWithAncestors(ImmutableOntology<?, ?> ontology, Se...
### Question: TermAnnotations { public static Map<TermId, Collection<String>> constructTermAnnotationToLabelsMap( Ontology<?, ?> ontology, Collection<? extends TermAnnotation> annotations) { final Map<TermId, Collection<String>> result = new HashMap<>(); for (TermAnnotation anno : annotations) { for (TermId termId : on...
### Question: ImmutableTermId implements TermId { @Override public int compareTo(TermId that) { return ComparisonChain.start().compare(this.getPrefix(), that.getPrefix()) .compare(this.getId(), that.getId()).result(); } ImmutableTermId(TermPrefix prefix, String id); static ImmutableTermId constructWithPrefix(String ter...
### Question: ImmutableTermId implements TermId { @Override public boolean equals(Object obj) { if (this == obj) { return true; } else if (obj instanceof TermId) { final TermId that = (TermId) obj; return this.prefix.equals(that.getPrefix()) && (this.id.equals(that.getId())); } else { return false; } } ImmutableTermId(...
### Question: ImmutableTermId implements TermId { @Override public String toString() { return "ImmutableTermId [prefix=" + prefix + ", id=" + id + "]"; } ImmutableTermId(TermPrefix prefix, String id); static ImmutableTermId constructWithPrefix(String termIdString); @Override int compareTo(TermId that); @Override TermPr...
### Question: ImmutableTermPrefix implements TermPrefix { @Override public int compareTo(TermPrefix o) { if (this == o) { return 0; } else { return value.compareTo(o.getValue()); } } ImmutableTermPrefix(String value); @Override int compareTo(TermPrefix o); @Override String getValue(); @Override String toString(); @Over...
### Question: ImmutableTermPrefix implements TermPrefix { @Override public String getValue() { return value; } ImmutableTermPrefix(String value); @Override int compareTo(TermPrefix o); @Override String getValue(); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj); }### Answer:...
### Question: ImmutableTermPrefix implements TermPrefix { @Override public String toString() { return "ImmutableTermPrefix [value=" + value + "]"; } ImmutableTermPrefix(String value); @Override int compareTo(TermPrefix o); @Override String getValue(); @Override String toString(); @Override int hashCode(); @Override boo...
### Question: ImmutableEdge implements Edge<V> { @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } @SuppressWarnings("unchecked") ImmutableEdge<V> other = (ImmutableEdge<V>) obj; if (dest == null) { if (...
### Question: SimpleFeatureVectorSimilarity implements Similarity { @Override public double computeScore(Collection<TermId> query, Collection<TermId> target) { return Sets.intersection(Sets.newHashSet(query), Sets.newHashSet(target)).size(); } @Override String getName(); @Override String getParameters(); @Override boo...
### Question: JaccardSimilarity implements Similarity { @Override public double computeScore(Collection<TermId> query, Collection<TermId> target) { final Set<TermId> termIdsQuery = ontology.getAllAncestorTermIds(query, false); final Set<TermId> termIdsTarget = ontology.getAllAncestorTermIds(target, false); double...
### Question: CosineSimilarity implements Similarity { @Override public double computeScore(Collection<TermId> query, Collection<TermId> target) { final Set<TermId> termIdsQuery = ontology.getAllAncestorTermIds(query, false); final Set<TermId> termIdsTarget = ontology.getAllAncestorTermIds(target, false); return Sets.i...
### Question: PrecomputingPairwiseResnikSimilarity implements PairwiseSimilarity, Serializable { @Override public double computeScore(TermId query, TermId target) { return precomputedScores.get(query, target); } PrecomputingPairwiseResnikSimilarity(Ontology<T, R> ontology, Map<TermId, Double> termToIc, ...
### Question: TermOverlapSimilarity implements Similarity { @Override public double computeScore(Collection<TermId> query, Collection<TermId> target) { final Set<TermId> termIdsQuery = ontology.getAllAncestorTermIds(query, false); final Set<TermId> termIdsTarget = ontology.getAllAncestorTermIds(target, false); do...
### Question: PairwiseResnikSimilarity implements PairwiseSimilarity { @Override public double computeScore(TermId query, TermId target) { return computeScoreImpl(query, target); } protected PairwiseResnikSimilarity(); PairwiseResnikSimilarity(Ontology<T, R> ontology, Map<TermId, Double> termToIc); double compu...
### Question: ResnikSimilarity extends AbstractCommonAncestorSimilarity<T, R> { @Override public String getName() { return "Resnik similarity"; } ResnikSimilarity(Ontology<T, R> ontology, Map<TermId, Double> termToIc, boolean symmetric); ResnikSimilarity(PairwiseSimilarity pairwiseSimilarity, boolean symmetric);...
### Question: BronWatchList { public boolean isWatched(Entiteit entity) { return list.containsKey(Hibernate.getClass(entity)); } boolean isWatched(Entiteit entity); boolean isWatched(Entiteit entiteit, String property); static boolean isSleutelWaarde(Entiteit entiteit, String expression); static boolean isSleutelWaard...
### Question: ResourceUtil { public static void flush(Object objectToFlush) { if (objectToFlush instanceof Flushable) { Flushable flushable = (Flushable) objectToFlush; try { flushable.flush(); } catch (IOException e) { log.error(e.toString(), e); throw new RuntimeException(e); } } } private ResourceUtil(); static voi...
### Question: Utf8BufferedWriter extends BufferedWriter { public void writeByteOrderMark() throws IOException { write(new String(BOM, "UTF-8")); } Utf8BufferedWriter(File file); Utf8BufferedWriter(File file, int size); void writeByteOrderMark(); static byte[] BOM; }### Answer: @Test public void testWriteByteOrderMark(...
### Question: BronStateChange implements Serializable { @Override public String toString() { return entity.getClass().getSimpleName() + "." + propertyName + ": " + toString(previousValue) + " -> " + toString(currentValue); } BronStateChange(IdObject entity, String propertyName, Object previousValue, Object currentVa...
### Question: Token extends InstellingEntiteit { public String getSerienummer() { return serienummer; } Token(String serienummer, String applicatie, String blob); protected Token(); boolean verifieerPassword(String password); @SuppressWarnings("hiding") void geefUit(Account gebruiker); void neemIn(); void meldDefect()...
### Question: Token extends InstellingEntiteit { public TokenStatus getStatus() { return status; } Token(String serienummer, String applicatie, String blob); protected Token(); boolean verifieerPassword(String password); @SuppressWarnings("hiding") void geefUit(Account gebruiker); void neemIn(); void meldDefect(); voi...
### Question: BronWatchList { public static boolean isSleutelWaarde(Entiteit entiteit, String expression) { Class< ? > key = Hibernate.getClass(entiteit); HashMap<String, Property> properties = list.get(key); if (properties != null && properties.containsKey(expression)) { Property property = properties.get(expression);...
### Question: Brin extends ExterneOrganisatie { public Brin() { } Brin(); Brin(String brincode); @Exportable String getCode(); void setCode(String brincode); static boolean testBrincode(String brincode); @Override String toString(); void setOnderwijssector(Onderwijssector onderwijssector); Onderwijssector getOnderwijs...
### Question: Brin extends ExterneOrganisatie { @Exportable public Integer getVestigingsVolgnummer() { String brincode = getCode(); if (brincode != null) { Matcher matcher = BRIN_REGEXP.matcher(brincode); if (!matcher.matches()) { Asserts.fail(brincode + " is geen geldige BRIN code"); } String volgnummer = matcher.grou...
### Question: Asserts { public static void assertNotNull(final String parameter, final Object waarde) { if (log.isDebugEnabled()) { String waardeText = String.valueOf(waarde); waardeText = waardeText.substring(0, Math.min(waardeText.length(), 16)); log.debug("Controleer dat " + parameter + " niet null is, huidige waard...
### Question: Asserts { public static void assertNotEmpty(String parameter, Object waarde) { assertNotNull(parameter, waarde); if ("".equals(waarde.toString().trim())) { String bericht = "Parameter " + parameter + " is leeg"; throw new IllegalArgumentException(bericht); } } static void assertNotNull(final String param...
### Question: SpringBootExample implements CommandLineRunner { public static void main(String[] args) { SpringApplication.run(SpringBootExample.class, args); } static void main(String[] args); @Override void run(String... args); }### Answer: @Test public void shouldExecuteMainWithoutExceptions() { SpringBootExample.m...
### Question: WritableMapConfigurationSource extends MapConfigurationSource implements WritableConfigurationSource { @Override public OptionalValue<String> removeValue(String key, Map<String, String> attributes) { requireNonNull(key, "key cannot be null"); return source.containsKey(key) ? present(source.remove(key)) : ...
### Question: PropertiesConfigurationSource implements IterableConfigurationSource { @Override public Iterable<ConfigurationEntry> getAllConfigurationEntries() { Map<String, String> map = source.entrySet().stream() .filter(e -> e.getValue() instanceof String) .collect(toMap(Object::toString, e -> (String) e.getValue())...
### Question: PatternConverter implements TypeConverter<Pattern> { @Override public Pattern fromString(Type type, String value, Map<String, String> attributes) { requireNonNull(type, "type cannot be null"); try { return (value == null) ? null : Pattern.compile(value); } catch (PatternSyntaxException e) { throw new Ille...
### Question: PatternConverter implements TypeConverter<Pattern> { @Override public String toString(Type type, Pattern value, Map<String, String> attributes) { requireNonNull(type, "type cannot be null"); return Objects.toString(value, null); } @Override boolean isApplicable(Type type, Map<String, String> attributes);...
### Question: PatternConverter implements TypeConverter<Pattern> { @Override public boolean isApplicable(Type type, Map<String, String> attributes) { requireNonNull(type, "type cannot be null"); return type instanceof Class<?> && Pattern.class.isAssignableFrom((Class<?>) type); } @Override boolean isApplicable(Type ty...
### Question: ObjectBuilder { ObjectBuilder beginList() { return beginList(new ArrayList<>()); } }### Answer: @Test public void shouldFailInCaseEndingObjectWhenArrayWasBegun() { assertThatThrowExceptionOfType( new ObjectBuilder().beginList()::endMap, IllegalStateException.class); }
### Question: ObjectBuilder { ObjectBuilder beginMap() { return beginMap(new LinkedHashMap<>()); } }### Answer: @Test public void shouldFailInCaseEndingArrayWhenObjectWasBegun() { assertThatThrowExceptionOfType( new ObjectBuilder().beginMap()::endList, IllegalStateException.class); }
### Question: TypeConverterUtils { static int notEscapedIndexOf(CharSequence value, int startPos, char character) { Objects.requireNonNull(value, "value must not be null"); char prev = 0xffff; for (int i = max(startPos, 0), len = value.length(); i < len; i++) { char current = value.charAt(i); if (current == character) ...
### Question: PeriodConverter implements TypeConverter<Period> { @Override public Period fromString(Type type, String value, Map<String, String> attributes) { requireNonNull(type, "type cannot be null"); try { return value == null ? null : Period.parse(value); } catch (DateTimeParseException e) { throw new IllegalArgum...
### Question: PeriodConverter implements TypeConverter<Period> { @Override public String toString(Type type, Period value, Map<String, String> attributes) { requireNonNull(type, "type cannot be null"); return Objects.toString(value, null); } @Override boolean isApplicable(Type type, Map<String, String> attributes); @O...
### Question: PeriodConverter implements TypeConverter<Period> { @Override public boolean isApplicable(Type type, Map<String, String> attributes) { requireNonNull(type, "type cannot be null"); return type instanceof Class<?> && Period.class.isAssignableFrom((Class<?>) type); } @Override boolean isApplicable(Type type,...
### Question: LongConverter extends AbstractNumberConverter<Long> { @Override public boolean isApplicable(Type type, Map<String, String> attributes) { return isApplicable(type, Long.class, Long.TYPE); } @Override boolean isApplicable(Type type, Map<String, String> attributes); }### Answer: @Test public void shouldBeA...
### Question: OffsetDateTimeConverter extends AbstractTemporalAccessorConverter<OffsetDateTime> { @Override public boolean isApplicable(Type type, Map<String, String> attributes) { requireNonNull(type, "type cannot be null"); return type instanceof Class<?> && OffsetDateTime.class.isAssignableFrom((Class<?>) type); } ...
### Question: CharacterConverter implements TypeConverter<Character> { @Override public String toString(Type type, Character value, Map<String, String> attributes) { requireNonNull(type, "type cannot be null"); return value == null ? null : escapeJava(value.toString()); } @Override boolean isApplicable(Type type, Map<...
### Question: CharacterConverter implements TypeConverter<Character> { @Override public boolean isApplicable(Type type, Map<String, String> attributes) { requireNonNull(type, "type cannot be null"); return type instanceof Class<?> && (Character.class.isAssignableFrom((Class<?>) type) || Character.TYPE.isAssignableFrom(...
### Question: DurationConverter implements TypeConverter<Duration> { @Override public boolean isApplicable(Type type, Map<String, String> attributes) { requireNonNull(type, "type cannot be null"); return type instanceof Class<?> && Duration.class.isAssignableFrom((Class<?>) type); } @Override boolean isApplicable(Type...
### Question: ByteConverter extends AbstractNumberConverter<Byte> { @Override public boolean isApplicable(Type type, Map<String, String> attributes) { return isApplicable(type, Byte.class, Byte.TYPE); } @Override boolean isApplicable(Type type, Map<String, String> attributes); }### Answer: @Test public void shouldBeA...
### Question: LocalDateTimeConverter extends AbstractTemporalAccessorConverter<LocalDateTime> { @Override public boolean isApplicable(Type type, Map<String, String> attributes) { requireNonNull(type, "type cannot be null"); return type instanceof Class<?> && LocalDateTime.class.isAssignableFrom((Class<?>) type); } @Ov...
### Question: BigDecimalConverter extends AbstractNumberConverter<BigDecimal> { @Override public boolean isApplicable(Type type, Map<String, String> attributes) { return isApplicable(type, BigDecimal.class, null); } @Override boolean isApplicable(Type type, Map<String, String> attributes); }### Answer: @Test public v...
### Question: IntegerConverter extends AbstractNumberConverter<Integer> { @Override public boolean isApplicable(Type type, Map<String, String> attributes) { return isApplicable(type, Integer.class, Integer.TYPE); } @Override boolean isApplicable(Type type, Map<String, String> attributes); }### Answer: @Test public vo...
### Question: DoubleConverter extends AbstractNumberConverter<Double> { @Override public boolean isApplicable(Type type, Map<String, String> attributes) { return isApplicable(type, Double.class, Double.TYPE); } @Override boolean isApplicable(Type type, Map<String, String> attributes); }### Answer: @Test public void s...
### Question: CurrencyConverter implements TypeConverter<Currency> { @Override public boolean isApplicable(Type type, Map<String, String> attributes) { requireNonNull(type, "type cannot be null"); return type instanceof Class<?> && Currency.class.isAssignableFrom((Class<?>) type); } @Override boolean isApplicable(Type...
### Question: YamlConverter implements TypeConverter<T> { @Override public boolean isApplicable(Type type, Map<String, String> attributes) { requireNonNull(type, "type cannot be null"); String converter = (attributes == null) ? null : attributes.get(CONVERTER); return ignoreConverterAttribute || Objects.equals(converte...
### Question: CurrencyConverter implements TypeConverter<Currency> { @Override public String toString(Type type, Currency value, Map<String, String> attributes) { requireNonNull(type, "type cannot be null"); return value == null ? null : value.getCurrencyCode(); } @Override boolean isApplicable(Type type, Map<String, ...
### Question: CurrencyConverter implements TypeConverter<Currency> { @Override public Currency fromString(Type type, String value, Map<String, String> attributes) { requireNonNull(type, "type cannot be null"); return value == null ? null : Currency.getInstance(value); } @Override boolean isApplicable(Type type, Map<St...
### Question: BooleanConverter implements TypeConverter<Boolean> { @Override public boolean isApplicable(Type type, Map<String, String> attributes) { requireNonNull(type, "type cannot be null"); return type instanceof Class<?> && (Boolean.class.isAssignableFrom((Class<?>) type) || Boolean.TYPE.isAssignableFrom((Class<?...
### Question: InstantConverter extends AbstractTemporalAccessorConverter<Instant> { @Override public boolean isApplicable(Type type, Map<String, String> attributes) { requireNonNull(type, "type cannot be null"); return type instanceof Class<?> && Instant.class.isAssignableFrom((Class<?>) type); } @Override boolean isA...
### Question: StringConverter implements TypeConverter<String> { @Override public boolean isApplicable(Type type, Map<String, String> attributes) { requireNonNull(type, "type cannot be null"); return type instanceof Class<?> && String.class.isAssignableFrom((Class<?>) type); } StringConverter(boolean escape); StringCo...
### Question: StringConverter implements TypeConverter<String> { @Override public String fromString(Type type, String value, Map<String, String> attributes) { requireNonNull(type, "type cannot be null"); return shouldEscape(attributes) ? unescapeJava(value) : value; } StringConverter(boolean escape); StringConverter()...
### Question: GenericsExample { public static void main(String[] args) { new GenericsExample().run(); } static void main(String[] args); }### Answer: @Test public void shouldExecuteMainWithoutExceptions() { GenericsExample.main(new String[0]); }
### Question: StringConverter implements TypeConverter<String> { @Override public String toString(Type type, String value, Map<String, String> attributes) { requireNonNull(type, "type cannot be null"); return shouldEscape(attributes) ? escapeJava(value) : value; } StringConverter(boolean escape); StringConverter(); @O...
### Question: ChainedTypeConverter implements TypeConverter<Object> { @Override public boolean isApplicable(Type type, Map<String, String> attributes) { requireNonNull(type, "type cannot be null"); return converterFor(type, attributes, false) != null; } ChainedTypeConverter(List<TypeConverter<?>> converters); ChainedT...
### Question: ChainedTypeConverter implements TypeConverter<Object> { @Override public Object fromString(Type type, String value, Map<String, String> attributes) { requireNonNull(type, "type cannot be null"); return converterFor(type, attributes).fromString(type, value, attributes); } ChainedTypeConverter(List<TypeConv...
### Question: FloatConverter extends AbstractNumberConverter<Float> { @Override public boolean isApplicable(Type type, Map<String, String> attributes) { return isApplicable(type, Float.class, Float.TYPE); } @Override boolean isApplicable(Type type, Map<String, String> attributes); }### Answer: @Test public void shoul...
### Question: UrlConverter implements TypeConverter<URL> { @Override public boolean isApplicable(Type type, Map<String, String> attributes) { requireNonNull(type, "type cannot be null"); return type instanceof Class<?> && URL.class.isAssignableFrom((Class<?>) type); } @Override boolean isApplicable(Type type, Map<Stri...
### Question: UrlConverter implements TypeConverter<URL> { @Override public String toString(Type type, URL value, Map<String, String> attributes) { requireNonNull(type, "type cannot be null"); return Objects.toString(value, null); } @Override boolean isApplicable(Type type, Map<String, String> attributes); @Override U...
### Question: UrlConverter implements TypeConverter<URL> { @Override public URL fromString(Type type, String value, Map<String, String> attributes) { requireNonNull(type, "type cannot be null"); if (value == null) { return null; } try { return new URL(value); } catch (MalformedURLException e) { throw new IllegalArgumen...
### Question: ShortConverter extends AbstractNumberConverter<Short> { @Override public boolean isApplicable(Type type, Map<String, String> attributes) { return isApplicable(type, Short.class, Short.TYPE); } @Override boolean isApplicable(Type type, Map<String, String> attributes); }### Answer: @Test public void shoul...
### Question: EnumConverter implements TypeConverter<Enum<?>> { @Override public boolean isApplicable(Type type, Map<String, String> attributes) { requireNonNull(type, "type cannot be null"); return type instanceof Class<?> && Enum.class.isAssignableFrom((Class<?>) type); } @Override boolean isApplicable(Type type, Ma...
### Question: EnumConverter implements TypeConverter<Enum<?>> { @SuppressWarnings("unchecked") @Override public Enum<?> fromString(Type type, String value, Map<String, String> attributes) { requireNonNull(type, "type cannot be null"); return value == null ? null : toEnumValue((Class<Enum<?>>) type, value); } @Override...
### Question: EnumConverter implements TypeConverter<Enum<?>> { @Override public String toString(Type type, Enum<?> value, Map<String, String> attributes) { requireNonNull(type, "type cannot be null"); return value == null ? null : value.name(); } @Override boolean isApplicable(Type type, Map<String, String> attribute...
### Question: JsonConverter implements TypeConverter<T> { @Override public boolean isApplicable(Type type, Map<String, String> attributes) { requireNonNull(type, "type cannot be null"); String converter = (attributes == null) ? null : attributes.get(CONVERTER); return ignoreConverterAttribute || Objects.equals(converte...
### Question: MetaDataExample { public static void main(String[] args) { new MetaDataExample().run(); } static void main(String[] args); }### Answer: @Test public void shouldExecuteMainWithoutExceptions() { MetaDataExample.main(new String[0]); }
### Question: JsonConverter implements TypeConverter<T> { @Override public String toString(Type type, T value, Map<String, String> attributes) { requireNonNull(type, "type cannot be null"); if (value == null) { return null; } try { ObjectWriter objectWriter = objectMapper.writer(); return objectWriter.writeValueAsStrin...
### Question: SpringAnnotationBasedExample { public static void main(String[] args) { try (AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(SpringAnnotationBasedExample.class)) { context.getBean(SpringAnnotationBasedExample.class).run(); } } static void main(String[] args); }### Ans...
### Question: SpringExample { public static void main(String[] args) { new SpringExample().run(); } static void main(String[] args); }### Answer: @Test public void shouldExecuteMainWithoutExceptions() { SpringExample.main(new String[0]); }
### Question: CoreExample { public static void main(String[] args) { new CoreExample().run(); } static void main(String[] args); }### Answer: @Test public void shouldExecuteMainWithoutExceptions() { CoreExample.main(new String[0]); }
### Question: MethodsProvider { public Collection<Method> getAllDeclaredMethods(Class<?> configurationType) { Class<?> type = configurationType; Set<MethodWrapper> methods = new LinkedHashSet<>(addMethods(type.getMethods())); if (type.getSuperclass() != null) { do { methods.addAll(addMethods(type.getDeclaredMethods()))...
### Question: PropertySourceConfigurationSource implements ConfigurationSource, BeanFactoryAware, EnvironmentAware, InitializingBean { @Override public OptionalValue<String> getValue(String key, Map<String, String> attributes) { requireNonNull(key, "key cannot be null"); for (PropertySource<?> propertySource : flattene...
### Question: AttributesUtils implements Serializable { public static Map<String, String> attributes(Map<String, String> attributes) { return getCached(attributes, true); } private AttributesUtils(); static Map<String, String> attributes(Map<String, String> attributes); static Map<String, String> mergeAttributes(Map<S...
### Question: AttributesUtils implements Serializable { public static Map<String, String> mergeAttributes(Map<String, String> parent, Map<String, String> child) { if (parent == null) { return getCached(child, true); } if (child == null) { return getCached(parent, true); } Map<String, String> merged = new LinkedHashMap<...
### Question: CachingTypeConverter implements TypeConverter<T>, InitializingBean { @SuppressWarnings("unchecked") @Override public T fromString(Type type, String value, Map<String, String> attributes) { requireNonNull(type, "type cannot be null"); SimpleKey key = new SimpleKey(type, attributes, value); ValueWrapper val...
### Question: PropertyUtils { public static Object getProperty(Object bean, String name) { requireNonNull(bean, "bean cannot be null"); requireNonNull(name, "name cannot be null"); Class<?> beanClass = bean.getClass(); try { PropertyDescriptor descriptor = findPropertyDescriptor(beanClass, name); Method readMethod = de...
### Question: JaxbConverter implements TypeConverter<T> { @Override public boolean isApplicable(Type type, Map<String, String> attributes) { requireNonNull(type, "type cannot be null"); return type instanceof Class && ((AnnotatedElement) type).getAnnotation(XmlRootElement.class) != null; } @Override boolean isApplicab...
### Question: PropertyUtils { public static String getPropertyName(Method method) { requireNonNull(method, "method cannot be null"); String name = method.getName(); if (name.startsWith("set")) { if (method.getParameterCount() != 1) { throw new IllegalArgumentException("Method " + method + " is not a valid setter."); } ...
### Question: MultiConfigurationSource implements ConfigurationSource { @Override public OptionalValue<String> getValue(String key, Map<String, String> attributes) { requireNonNull(key, "key cannot be null"); for (ConfigurationSource source : sources) { OptionalValue<String> value = source.getValue(key, attributes); if...
### Question: MultiConfigurationSource implements ConfigurationSource { @Override public ConfigurationEntry findEntry(Collection<String> keys, Map<String, String> attributes) { requireNonNull(keys, "keys cannot be null"); for (ConfigurationSource source : sources) { ConfigurationEntry entry = source.findEntry(keys, att...
### Question: MapConfigurationSource implements IterableConfigurationSource { @Override public OptionalValue<String> getValue(String key, Map<String, String> attributes) { requireNonNull(key, "key cannot be null"); String value = source.get(key); return value != null || source.containsKey(key) ? present(value) : absent...
### Question: MapConfigurationSource implements IterableConfigurationSource { @Override public Iterable<ConfigurationEntry> getAllConfigurationEntries() { return new MapConfigurationEntryIterable(source); } MapConfigurationSource(Map<String, String> source); @Override OptionalValue<String> getValue(String key, Map<Stri...
### Question: WritableMapConfigurationSource extends MapConfigurationSource implements WritableConfigurationSource { @Override public void setValue(String key, String value, Map<String, String> attributes) { requireNonNull(key, "key cannot be null"); source.put(key, value); } WritableMapConfigurationSource(Map<String, ...
### Question: AvgLaborCostCalcForOrderDetailsHooks { public void enabledButtonForCopyNorms(final ViewDefinitionState view) { WindowComponent window = (WindowComponent) view.getComponentByReference("window"); RibbonActionItem copyToOperationsNorms = window.getRibbon().getGroupByName("hourlyCostNorms") .getItemByName("co...
### Question: GenerateProductionBalanceWithCosts implements Observer { void generateBalanceWithCostsReport(final Entity productionBalance) { Locale locale = LocaleContextHolder.getLocale(); String localePrefix = "productionCounting.productionBalanceWithCosts.report.fileName"; Entity productionBalanceWithFileName = file...
### Question: ProductDetailsListenersT { public final void addTechnologyGroup(final ViewDefinitionState view, final ComponentState componentState, final String[] args) { FormComponent productForm = (FormComponent) view.getComponentByReference(L_FORM); Entity product = productForm.getEntity(); if (product.getId() == nul...
### Question: CostNormsForOperationService { public void fillCurrencyFields(final ViewDefinitionState view) { String currencyStringCode = currencyService.getCurrencyAlphabeticCode(); FieldComponent component = null; for (String componentReference : Sets.newHashSet("pieceworkCostCURRENCY", "laborHourlyCostCURRENCY", "ma...
### Question: ProductionLinesServiceImpl implements ProductionLinesService { @Override public Integer getWorkstationTypesCount(final Entity operationComponent, final Entity productionLine) { List<Entity> workstationTypeComponents = productionLine.getHasManyField(ProductionLineFields.WORKSTATION_TYPE_COMPONENTS); Entity...