method2testcases
stringlengths
118
6.63k
### Question: CompositeAspectDefinition implements LinkkiAspectDefinition { @Override public boolean supports(WrapperType type) { return aspectDefinitions.stream() .anyMatch(d -> d.supports(type)); } CompositeAspectDefinition(@NonNull LinkkiAspectDefinition... aspectDefinitions); CompositeAspectDefinition(List<LinkkiA...
### Question: ApplicableTypeAspectDefinition extends ApplicableAspectDefinition { public static ApplicableTypeAspectDefinition ifComponentTypeIs(Class<?> applicableType, LinkkiAspectDefinition wrappedAspectDefinition) { return new ApplicableTypeAspectDefinition(wrappedAspectDefinition, applicableType); } private Appli...
### Question: Binder { public void setupBindings(BindingContext bindingContext) { addFieldBindings(bindingContext); addMethodBindings(bindingContext); } Binder(Object view, Object pmo); void setupBindings(BindingContext bindingContext); }### Answer: @Test public void testSetupBindings() { TestView view = new TestView(...
### Question: BeanUtils { public static Method getMethod(Class<?> clazz, String name, Class<?>... parameterTypes) { try { return clazz.getMethod(name, parameterTypes); } catch (NoSuchMethodException e) { throw new IllegalArgumentException(e); } catch (SecurityException e) { throw new IllegalStateException(e); } } priva...
### Question: Classes { public static <T> T instantiate(Class<T> clazz) { try { return clazz .getConstructor() .newInstance(); } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) { throw new IllegalArgumentExcepti...
### Question: BehaviorDependentDispatcher extends AbstractPropertyDispatcherDecorator { @SuppressWarnings("unchecked") @Override public <T> T pull(Aspect<T> aspect) { if (aspect.getName().equals(VisibleAspectDefinition.NAME) && !isConsensus(forBoundObjectAndProperty(PropertyBehavior::isVisible))) { return (T)Boolean.FA...
### Question: BehaviorDependentDispatcher extends AbstractPropertyDispatcherDecorator { @Override public MessageList getMessages(MessageList messageList) { if (isConsensus(forBoundObjectAndProperty(PropertyBehavior::isShowValidationMessages))) { return super.getMessages(messageList); } else { return new MessageList(); ...
### Question: BehaviorDependentDispatcher extends AbstractPropertyDispatcherDecorator { @Override public <T> boolean isPushable(Aspect<T> aspect) { if (aspect.getName().equals(LinkkiAspectDefinition.VALUE_ASPECT_NAME) && !isConsensus(forBoundObjectAndProperty(PropertyBehavior::isWritable))) { return false; } else { ret...
### Question: PropertyAccessorCache { @SuppressWarnings("unchecked") public static <T> PropertyAccessor<T, ?> get(Class<T> clazz, String property) { return (PropertyAccessor<T, ?>)ACCESSOR_CACHE.get(new CacheKey(clazz, property)); } private PropertyAccessorCache(); @SuppressWarnings("unchecked") static PropertyAccesso...
### Question: ReadMethod extends AbstractMethod<T> { public V readValue(T boundObject) { if (canRead()) { return readValueWithExceptionHandling(boundObject); } else { throw new IllegalStateException( "Cannot find getter method for " + boundObject.getClass().getName() + "#" + getPropertyName()); } } ReadMethod(PropertyA...
### Question: ReadMethod extends AbstractMethod<T> { public boolean canRead() { return hasMethod(); } ReadMethod(PropertyAccessDescriptor<T, V> descriptor); boolean canRead(); V readValue(T boundObject); @SuppressWarnings("unchecked") Class<V> getReturnType(); }### Answer: @Test public void testReadValue_NoGetterMetho...
### Question: WriteMethod extends AbstractMethod<T> { public void writeValue(T target, @CheckForNull V value) { try { setter().accept(target, value); } catch (IllegalArgumentException | IllegalStateException e) { throw new LinkkiBindingException( "Cannot write value: " + value + " in " + getBoundClass() + "#" + getProp...
### Question: PropertyAccessor { public V getPropertyValue(T boundObject) { return readMethod.readValue(boundObject); } PropertyAccessor(Class<? extends T> boundClass, String propertyName); String getPropertyName(); V getPropertyValue(T boundObject); void setPropertyValue(T boundObject, @CheckForNull V value); void inv...
### Question: PropertyAccessor { public void setPropertyValue(T boundObject, @CheckForNull V value) { writeMethod.writeValue(boundObject, value); } PropertyAccessor(Class<? extends T> boundClass, String propertyName); String getPropertyName(); V getPropertyValue(T boundObject); void setPropertyValue(T boundObject, @Che...
### Question: PropertyAccessor { public String getPropertyName() { return propertyName; } PropertyAccessor(Class<? extends T> boundClass, String propertyName); String getPropertyName(); V getPropertyValue(T boundObject); void setPropertyValue(T boundObject, @CheckForNull V value); void invoke(T boundObject); boolean ca...
### Question: PropertyAccessor { public boolean canRead() { return readMethod.canRead(); } PropertyAccessor(Class<? extends T> boundClass, String propertyName); String getPropertyName(); V getPropertyValue(T boundObject); void setPropertyValue(T boundObject, @CheckForNull V value); void invoke(T boundObject); boolean c...
### Question: PropertyAccessor { public Class<?> getValueClass() { return readMethod.getReturnType(); } PropertyAccessor(Class<? extends T> boundClass, String propertyName); String getPropertyName(); V getPropertyValue(T boundObject); void setPropertyValue(T boundObject, @CheckForNull V value); void invoke(T boundObjec...
### Question: AbstractMethod { protected boolean hasMethod() { return getReflectionMethod().isPresent(); } AbstractMethod(PropertyAccessDescriptor<T, ?> descriptor, Supplier<Optional<Method>> methodSupplier); }### Answer: @Test public void testHasNoMethod() { when(descriptor.getReflectionWriteMethod()).thenReturn(laz...
### Question: PropertyNamingConvention { public String getValueProperty(String property) { return requireNonNull(property, "property must not be null"); } String getValueProperty(String property); String getEnabledProperty(String property); String getVisibleProperty(String property); String getMessagesProperty(String ...
### Question: PropertyNamingConvention { public String getEnabledProperty(String property) { return getCombinedPropertyName(property, ENABLED_PROPERTY_SUFFIX); } String getValueProperty(String property); String getEnabledProperty(String property); String getVisibleProperty(String property); String getMessagesProperty(...
### Question: PropertyNamingConvention { public String getVisibleProperty(String property) { return getCombinedPropertyName(property, VISIBLE_PROPERTY_SUFFIX); } String getValueProperty(String property); String getEnabledProperty(String property); String getVisibleProperty(String property); String getMessagesProperty(...
### Question: PropertyNamingConvention { public String getMessagesProperty(String property) { return getCombinedPropertyName(property, MESSAGES_PROPERTY_SUFFIX); } String getValueProperty(String property); String getEnabledProperty(String property); String getVisibleProperty(String property); String getMessagesPropert...
### Question: PropertyNamingConvention { public String getRequiredProperty(String property) { return getCombinedPropertyName(property, REQUIRED_PROPERTY_SUFFIX); } String getValueProperty(String property); String getEnabledProperty(String property); String getVisibleProperty(String property); String getMessagesPropert...
### Question: PropertyNamingConvention { public String getAvailableValuesProperty(String property) { return getCombinedPropertyName(property, AVAILABLE_VALUES_PROPERTY_SUFFIX); } String getValueProperty(String property); String getEnabledProperty(String property); String getVisibleProperty(String property); String get...
### Question: ReflectionPropertyDispatcher implements PropertyDispatcher { @Override public Class<?> getValueClass() { Object boundObject = getBoundObject(); if (boundObject != null && hasReadMethod(getProperty())) { Class<?> valueClass = getAccessor(getProperty()).getValueClass(); return valueClass; } else { return fa...
### Question: BeanUtils { public static Stream<Method> getMethods(Class<?> clazz, Predicate<Method> predicate) { return Arrays.stream(clazz.getMethods()) .filter(m -> !m.isSynthetic()) .filter(predicate); } private BeanUtils(); static BeanInfo getBeanInfo(Class<?> clazz); static Method getMethod(Class<?> clazz, String...
### Question: ReflectionPropertyDispatcher implements PropertyDispatcher { @Override public MessageList getMessages(MessageList messageList) { Object boundObject = getBoundObject(); if (boundObject == null) { return new MessageList(); } else { MessageList msgListForBoundObject = messageList.getMessagesFor(boundObject, ...
### Question: ReflectionPropertyDispatcher implements PropertyDispatcher { @Override public <V> void push(Aspect<V> aspect) { @CheckForNull Object boundObject = getBoundObject(); if (boundObject != null) { if (aspect.isValuePresent()) { callSetter(aspect); } else { invoke(aspect); } } } ReflectionPropertyDispatcher(Sup...
### Question: ReflectionPropertyDispatcher implements PropertyDispatcher { @Override public <V> boolean isPushable(Aspect<V> aspect) { @CheckForNull Object boundObject = getBoundObject(); if (boundObject == null) { return fallbackDispatcher.isPushable(aspect); } String propertyAspectName = getPropertyAspectName(aspect)...
### Question: BeanUtils { public static String getPropertyName(Method method) { return getPropertyName(method.getReturnType(), method.getName()); } private BeanUtils(); static BeanInfo getBeanInfo(Class<?> clazz); static Method getMethod(Class<?> clazz, String name, Class<?>... parameterTypes); static Optional<Method>...
### Question: AbstractPropertyDispatcherDecorator implements PropertyDispatcher { @Override public <T> T pull(Aspect<T> aspect) { return getWrappedDispatcher().pull(aspect); } AbstractPropertyDispatcherDecorator(PropertyDispatcher wrappedDispatcher); @Override Class<?> getValueClass(); @Override MessageList getMessages...
### Question: AbstractPropertyDispatcherDecorator implements PropertyDispatcher { @Override public Class<?> getValueClass() { return wrappedDispatcher.getValueClass(); } AbstractPropertyDispatcherDecorator(PropertyDispatcher wrappedDispatcher); @Override Class<?> getValueClass(); @Override MessageList getMessages(Messa...
### Question: AbstractPropertyDispatcherDecorator implements PropertyDispatcher { @Override public MessageList getMessages(MessageList messageList) { return getWrappedDispatcher().getMessages(messageList); } AbstractPropertyDispatcherDecorator(PropertyDispatcher wrappedDispatcher); @Override Class<?> getValueClass(); @...
### Question: AbstractPropertyDispatcherDecorator implements PropertyDispatcher { protected PropertyDispatcher getWrappedDispatcher() { return wrappedDispatcher; } AbstractPropertyDispatcherDecorator(PropertyDispatcher wrappedDispatcher); @Override Class<?> getValueClass(); @Override MessageList getMessages(MessageList...
### Question: ExceptionPropertyDispatcher implements PropertyDispatcher { @Override @CheckForNull public Object getBoundObject() { if (objects.size() > 0) { return objects.get(0); } else { throw new IllegalStateException( "ExceptionPropertyDispatcher has no presentation model object. " + "The bound object should be fou...
### Question: ExceptionPropertyDispatcher implements PropertyDispatcher { @Override public String toString() { return getClass().getSimpleName() + "[" + objects.stream().map((Object c) -> (c != null) ? c.getClass().getSimpleName() : "null") .collect(joining(",")) + "#" + getProperty() + "]"; } ExceptionPropertyDispatch...
### Question: ExceptionPropertyDispatcher implements PropertyDispatcher { @Override public MessageList getMessages(MessageList messageList) { return new MessageList(); } ExceptionPropertyDispatcher(String property, Object... objects); @Override Class<?> getValueClass(); @Override MessageList getMessages(MessageList mes...
### Question: ExceptionPropertyDispatcher implements PropertyDispatcher { @Override public <T> boolean isPushable(Aspect<T> aspect) { return false; } ExceptionPropertyDispatcher(String property, Object... objects); @Override Class<?> getValueClass(); @Override MessageList getMessages(MessageList messageList); @Override...
### Question: ExceptionPropertyDispatcher implements PropertyDispatcher { @Override public Class<?> getValueClass() { throw new IllegalStateException( missingMethodMessage("is/get" + StringUtils.capitalize(getProperty()), objects)); } ExceptionPropertyDispatcher(String property, Object... objects); @Override Class<?> g...
### Question: StaticValueDispatcher extends AbstractPropertyDispatcherDecorator { @SuppressWarnings("unchecked") @Override public <T> T pull(Aspect<T> aspect) { if (aspect.isValuePresent()) { T staticValue = aspect.getValue(); Object boundObject = getBoundObject(); if (staticValue instanceof String && boundObject != nu...
### Question: BindingContext implements UiUpdateObserver { @Deprecated public BindingContext add(Binding binding) { add(binding, UiFramework.getComponentWrapperFactory().createComponentWrapper(binding.getBoundComponent())); return this; } BindingContext(); BindingContext(String contextName); BindingContext(String con...
### Question: BindingContext implements UiUpdateObserver { public void modelChanged() { updateUI(); } BindingContext(); BindingContext(String contextName); BindingContext(String contextName, PropertyBehaviorProvider behaviorProvider, Handler afterUpdateHandler); BindingContext(String contextName, Propert...
### Question: BindingContext implements UiUpdateObserver { public void removeBindingsForComponent(Object uiComponent) { bindings.remove(uiComponent); UiFramework.getChildComponents(uiComponent) .iterator() .forEachRemaining(this::removeBindingsForComponent); getBindingStream() .filter(BindingContext.class::isInstance) ...
### Question: BindingContext implements UiUpdateObserver { public void removeBindingsForPmo(Object pmo) { bindings.values().removeIf(ref -> { Binding binding = ref.get(); return binding != null && binding.getPmo() == pmo; }); getBindingStream() .filter(BindingContext.class::isInstance) .map(BindingContext.class::cast) ...
### Question: BindingContext implements UiUpdateObserver { public Binding bind(Object pmo, BindingDescriptor bindingDescriptor, ComponentWrapper componentWrapper) { requireNonNull(bindingDescriptor, "bindingDescriptor must not be null"); return bind(pmo, bindingDescriptor.getBoundProperty(), bindingDescriptor.getAspect...
### Question: BindingContext implements UiUpdateObserver { public Collection<Binding> getBindings() { return Collections.unmodifiableCollection(getBindingStream() .collect(toList())); } BindingContext(); BindingContext(String contextName); BindingContext(String contextName, PropertyBehaviorProvider behaviorProvider, ...
### Question: WrapperType { public boolean isAssignableFrom(@CheckForNull WrapperType type) { return this.equals(type) || (type != null && isAssignableFrom(type.getParent())); } private WrapperType(String name, WrapperType parent); static WrapperType of(String name); static WrapperType of(String name, WrapperType pare...
### Question: WrapperType { public boolean isRoot() { return this == ROOT; } private WrapperType(String name, WrapperType parent); static WrapperType of(String name); static WrapperType of(String name, WrapperType parent); @CheckForNull WrapperType getParent(); boolean isRoot(); boolean isAssignableFrom(@CheckForNull ...
### Question: WrapperType { @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } WrapperType other = (WrapperType)obj; if (!name.equals(other.name)) { return false; } if (parent == null) { if (other.parent ...
### Question: WrapperType { @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + name.hashCode(); if (parent != null) { result = parent.hashCode() + result * prime; } return result; } private WrapperType(String name, WrapperType parent); static WrapperType of(String name); ...
### Question: ElementBinding implements Binding { @Override public void updateFromPmo() { try { aspectUpdaters.updateUI(); componentWrapper.postUpdate(); } catch (RuntimeException e) { throw new LinkkiBindingException( "Error while updating UI (" + e.getMessage() + ") in " + toString(), e); } } ElementBinding(Component...
### Question: ElementBinding implements Binding { @Override public MessageList displayMessages(MessageList messages) { MessageList messagesForProperty = getRelevantMessages(messages); componentWrapper.setValidationMessages(messagesForProperty); return messagesForProperty; } ElementBinding(ComponentWrapper componentWrap...
### Question: MultiformatDateField extends DateField { public List<String> getAlternativeFormat() { return Arrays.asList(getState().getAlternativeFormats()); } MultiformatDateField(); MultiformatDateField(String caption, LocalDate value); MultiformatDateField(String caption); MultiformatDateField( ValueC...
### Question: ApplicationLayout extends VerticalLayout implements ViewDisplay { protected <T extends View & Component> T getCurrentView() { @SuppressWarnings("unchecked") T view = (T)mainArea; return view; } ApplicationLayout(ApplicationHeader header, @CheckForNull ApplicationFooter footer); @Override void showView(Vie...
### Question: ApplicationLayout extends VerticalLayout implements ViewDisplay { @Override public void showView(View view) { setMainArea(view.getViewComponent()); } ApplicationLayout(ApplicationHeader header, @CheckForNull ApplicationFooter footer); @Override void showView(View view); }### Answer: @Test public void tes...
### Question: LinkkiUi extends UI { @Override protected void init(VaadinRequest request) { requireNonNull(applicationConfig, "configure must be called before executing any initialization to set an ApplicationConfig"); ApplicationLayout applicationLayout = applicationConfig.createApplicationLayout(); setContent(applicat...
### Question: LinkkiUi extends UI { public ApplicationLayout getApplicationLayout() { return (ApplicationLayout)getContent(); } @SuppressFBWarnings(value = "NP_NONNULL_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR", justification = "applicationConfig/Layout will be non-null once configure was called") protected LinkkiUi(); @Su...
### Question: DateFormats { public static String getPattern(Locale locale) { requireNonNull(locale, "locale must not be null"); String registeredPattern = LANGUAGE_PATTERNS.get(locale.getLanguage()); if (registeredPattern != null) { return registeredPattern; } else { return defaultLocalePattern(locale); } } private Da...
### Question: SidebarSheet { protected void unselect() { getButton().removeStyleName(LinkkiApplicationTheme.SIDEBAR_SELECTED); getContent().setVisible(false); } @Deprecated SidebarSheet(Resource icon, Component content, String tooltip); SidebarSheet(Resource icon, String name, Component content); SidebarSheet(Resour...
### Question: SidebarSheet { protected void select() { uiUpdateObserver.ifPresent(UiUpdateObserver::uiUpdated); getContent().setVisible(true); getButton().addStyleName(LinkkiApplicationTheme.SIDEBAR_SELECTED); } @Deprecated SidebarSheet(Resource icon, Component content, String tooltip); SidebarSheet(Resource icon, St...
### Question: SidebarSheet { @Override public String toString() { return name; } @Deprecated SidebarSheet(Resource icon, Component content, String tooltip); SidebarSheet(Resource icon, String name, Component content); SidebarSheet(Resource icon, String name, Component content, UiUpdateObserver uiUpdateObserver); Si...
### Question: SidebarSheet { public String getId() { return id; } @Deprecated SidebarSheet(Resource icon, Component content, String tooltip); SidebarSheet(Resource icon, String name, Component content); SidebarSheet(Resource icon, String name, Component content, UiUpdateObserver uiUpdateObserver); SidebarSheet(Reso...
### Question: SidebarLayout extends CssLayout { public void select(String id) { getSidebarSheet(id).ifPresent(this::select); } SidebarLayout(); void addSheets(Stream<SidebarSheet> sheets); void addSheets(Iterable<SidebarSheet> sheets); void addSheets(@NonNull SidebarSheet... sheets); void addSheet(SidebarSheet sheet); ...
### Question: OkCancelDialog extends Window { public static Builder builder(String caption) { return new Builder(caption); } protected OkCancelDialog(String caption, Handler okHandler, Handler cancelHandler, ButtonOption buttonOption, Component... contentComponents); @Deprecated OkCancelDialog(String capt...
### Question: OkCancelDialog extends Window { @SuppressFBWarnings(value = "RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE", justification = "yeah, we know...") @Override public void setContent(@CheckForNull Component content) { if (mainArea == null) { super.setContent(content); } else { mainArea.removeAllComponents(); mainAr...
### Question: OkCancelDialog extends Window { protected void ok() { okHandler.apply(); } protected OkCancelDialog(String caption, Handler okHandler, Handler cancelHandler, ButtonOption buttonOption, Component... contentComponents); @Deprecated OkCancelDialog(String caption); @Deprecated OkCancelDialog(St...
### Question: DateFormats { public static void register(String languageCode, String pattern) { LANGUAGE_PATTERNS.put(languageCode, pattern); } private DateFormats(); static void register(String languageCode, String pattern); static String getPattern(Locale locale); static final String PATTERN_ISO; static final String ...
### Question: OkCancelDialog extends Window { public void setOkCaption(String okCaption) { okButton.setCaption(requireNonNull(okCaption, "okCaption must not be null")); } protected OkCancelDialog(String caption, Handler okHandler, Handler cancelHandler, ButtonOption buttonOption, Component... contentCompon...
### Question: OkCancelDialog extends Window { public void setCancelCaption(String cancelCaption) { if (cancelButton != null) { cancelButton.setCaption(requireNonNull(cancelCaption, "cancelCaption must not be null")); } else { throw new IllegalStateException("Dialog does not have a cancel button"); } } protected OkCanc...
### Question: PmoBasedDialogFactory { public OkCancelDialog newOkDialog(String title, Object... pmos) { return newOkCancelDialog(title, Handler.NOP_HANDLER, Handler.NOP_HANDLER, ButtonOption.OK_ONLY, pmos); } PmoBasedDialogFactory(); PmoBasedDialogFactory(ValidationService validationService); PmoBasedDialogFactory(Pr...
### Question: LazyInitializingMap { @CheckForNull public V getIfPresent(K key) { return internalMap.get(key); } LazyInitializingMap(Function<K, V> initializer); V get(K key); @CheckForNull V getIfPresent(K key); void clear(); @CheckForNull V remove(K key); }### Answer: @Test public void testGetIfPresent() { LazyInitia...
### Question: ComponentFactory { public static DateField newDateField() { MultiformatDateField field = new MultiformatDateField(); field.setRangeStart(LocalDate.ofYearDay(1, 1)); field.setRangeEnd(LocalDate.ofYearDay(9999, 365)); return field; } private ComponentFactory(); @Deprecated static Label addHorizontalSpacer(...
### Question: AbstractSection extends VerticalLayout { public void addHeaderButton(Button button) { button.addStyleName(LinkkiTheme.BUTTON_TEXT); headerComponents.add(button); header.addComponent(button, 1); updateHeader(); } AbstractSection(@CheckForNull String caption); AbstractSection(@CheckForNull String caption, ...
### Question: AbstractSection extends VerticalLayout { @Override public void setCaption(@CheckForNull String caption) { captionLabel.setValue(caption); captionLabel.setVisible(!StringUtils.isEmpty(caption)); updateHeader(); } AbstractSection(@CheckForNull String caption); AbstractSection(@CheckForNull String caption, ...
### Question: LazyInitializingMap { public V get(K key) { @CheckForNull V value = internalMap.computeIfAbsent(key, initializer); if (value == null) { throw new NullPointerException("Initializer must not create a null value"); } return value; } LazyInitializingMap(Function<K, V> initializer); V get(K key); @CheckForNull...
### Question: TabSheetArea extends TabSheet implements Area { @Override public void reloadBindings() { Component selectedTab = getSelectedTab(); if (selectedTab != null && selectedTab instanceof Page) { ((Page)selectedTab).reloadBindings(); } } TabSheetArea(); TabSheetArea(boolean preserveHeader); @PostConstruct final...
### Question: TabSheetArea extends TabSheet implements Area { protected List<Page> getTabs() { return StreamUtil.stream(this) .filter(c -> c instanceof Page) .map(c -> (Page)c) .collect(Collectors.toList()); } TabSheetArea(); TabSheetArea(boolean preserveHeader); @PostConstruct final void init(); @Deprecated TabSheet ...
### Question: LinkkiConverterRegistry implements Serializable { @SuppressWarnings("unchecked") public <P, M> Converter<P, M> findConverter(Type presentationType, Type modelType) { Class<?> rawPresentationType = getRawType(presentationType); Class<?> rawModelType = getRawType(modelType); if (isIdentityNecessary(rawPrese...
### Question: FormattedDoubleToStringConverter extends FormattedNumberToStringConverter<Double> { @Override protected Double convertToModel(Number value) { return value.doubleValue(); } FormattedDoubleToStringConverter(String format); }### Answer: @Test public void testConvertToModel() { FormattedDoubleToStringConver...
### Question: TwoDigitYearLocalDateConverter implements Converter<LocalDate, LocalDate> { @CheckForNull @Override public Result<LocalDate> convertToModel(@CheckForNull LocalDate value, ValueContext context) { if (value == null) { return Result.ok(null); } else { return Result.ok(TwoDigitYearUtil.convert(value)); } } @...
### Question: TwoDigitYearLocalDateConverter implements Converter<LocalDate, LocalDate> { @Override public LocalDate convertToPresentation(LocalDate value, ValueContext context) { return value; } @CheckForNull @Override Result<LocalDate> convertToModel(@CheckForNull LocalDate value, ValueContext context); @Override Lo...
### Question: FormattedIntegerToStringConverter extends FormattedNumberToStringConverter<Integer> { @Override protected Integer convertToModel(Number value) { return value.intValue(); } FormattedIntegerToStringConverter(String format); }### Answer: @Test public void testConvertToModel() { FormattedIntegerToStringConv...
### Question: HasItemsAvailableValuesAspectDefinition extends AvailableValuesAspectDefinition<HasItems<?>> { @SuppressWarnings("unchecked") private static void setDataProvider(HasItems<?> component, ListDataProvider<Object> listDataProvider) { if (component instanceof HasDataProvider) { ((HasDataProvider<Object>)compon...
### Question: HasItemsAvailableValuesAspectDefinition extends AvailableValuesAspectDefinition<HasItems<?>> { @SuppressWarnings("unchecked") @Override protected void handleNullItems(ComponentWrapper componentWrapper, List<?> items) { Object component = componentWrapper.getComponent(); if (component instanceof ComboBox<?...
### Question: CaptionAspectDefinition extends ModelToUiAspectDefinition<String> { @Override public Aspect<String> createAspect() { switch (captionType) { case AUTO: return StringUtils.isEmpty(staticCaption) ? Aspect.of(NAME) : Aspect.of(NAME, staticCaption); case DYNAMIC: return Aspect.of(NAME); case STATIC: return Asp...
### Question: CaptionAspectDefinition extends ModelToUiAspectDefinition<String> { @Override public Consumer<String> createComponentValueSetter(ComponentWrapper componentWrapper) { return caption -> ((Component)componentWrapper.getComponent()).setCaption(caption); } CaptionAspectDefinition(CaptionType captionType, Strin...
### Question: CaptionAspectDefinition extends ModelToUiAspectDefinition<String> { @Override public boolean supports(WrapperType type) { return super.supports(type) && !ColumnBasedComponentWrapper.COLUMN_BASED_TYPE.isAssignableFrom(type); } CaptionAspectDefinition(CaptionType captionType, String staticCaption); @Overrid...
### Question: LabelValueAspectDefinition extends ModelToUiAspectDefinition<Object> { @Override public Consumer<Object> createComponentValueSetter(ComponentWrapper componentWrapper) { return v -> ((Label)componentWrapper.getComponent()) .setValue(LabelValueAspectDefinition.toString(v)); } @Override Aspect<Object> creat...
### Question: AvailableValuesAspectDefinition implements LinkkiAspectDefinition { protected AvailableValuesType getAvailableValuesType() { return availableValuesType; } AvailableValuesAspectDefinition(AvailableValuesType availableValuesType, BiConsumer<C, ListDataProvider<Object>> dataProviderSetter); @Over...
### Question: AvailableValuesAspectDefinition implements LinkkiAspectDefinition { protected <T extends Enum<T>> List<?> getValuesDerivedFromDatatype(String propertyName, Class<?> valueClass) { if (valueClass.isEnum()) { @SuppressWarnings("unchecked") Class<T> enumType = (Class<T>)valueClass; return AvailableValuesProvi...
### Question: DateFormatRegistry { @Deprecated public String getPattern(Locale locale) { requireNonNull(locale, "locale must not be null"); String registeredPattern = languagePatterns.get(locale.getLanguage()); if (registeredPattern != null) { return registeredPattern; } else { return defaultLocalePattern(locale); } } ...
### Question: AvailableValuesAspectDefinition implements LinkkiAspectDefinition { @SuppressWarnings("unchecked") protected void setDataProvider(ComponentWrapper componentWrapper, ListDataProvider<Object> dataProvider) { dataProviderSetter.accept((C)componentWrapper.getComponent(), dataProvider); } AvailableValuesAspect...
### Question: AvailableValuesAspectDefinition implements LinkkiAspectDefinition { protected void handleNullItems(ComponentWrapper componentWrapper, List<?> items) { } AvailableValuesAspectDefinition(AvailableValuesType availableValuesType, BiConsumer<C, ListDataProvider<Object>> dataProviderSetter); @Overri...
### Question: AvailableValuesAspectDefinition implements LinkkiAspectDefinition { public Aspect<Collection<?>> createAspect(String propertyName, Class<?> valueClass) { AvailableValuesType type = getAvailableValuesType(); if (type == AvailableValuesType.DYNAMIC) { return Aspect.of(NAME); } else if (type == AvailableValu...
### Question: AvailableValuesAspectDefinition implements LinkkiAspectDefinition { @Override public Handler createUiUpdater(PropertyDispatcher propertyDispatcher, ComponentWrapper componentWrapper) { Aspect<Collection<?>> aspect = createAspect(propertyDispatcher.getProperty(), propertyDispatcher.getValueClass()); List<O...
### Question: TableCreator implements ColumnBasedComponentCreator { @SuppressWarnings("deprecation") @Override public ComponentWrapper createComponent(ContainerPmo<?> containerPmo) { com.vaadin.v7.ui.Table table = containerPmo.isHierarchical() ? new com.vaadin.v7.ui.TreeTable() : new com.vaadin.v7.ui.Table(); table.add...
### Question: HtmlSanitizer { public static @CheckForNull String sanitize(@CheckForNull String text) { if (StringUtils.isEmpty(text)) { return text; } else { return text.replaceAll("<(?!\\/?" + ALLOWED_TAGS + ">)", "&lt;") .replaceAll("(?<!<\\/?" + ALLOWED_TAGS + ")>", "&gt;"); } } private HtmlSanitizer(); static @Che...
### Question: LinkkiInMemoryContainer extends com.vaadin.v7.data.util.AbstractInMemoryContainer<T, Object, com.vaadin.v7.data.Item> implements com.vaadin.v7.data.Container.Hierarchical { public void setItems(Collection<? extends T> items) { requireNonNull(items, "items must not be null"); this.roots = new ArrayList<>(i...
### Question: LinkkiInMemoryContainer extends com.vaadin.v7.data.util.AbstractInMemoryContainer<T, Object, com.vaadin.v7.data.Item> implements com.vaadin.v7.data.Container.Hierarchical { @Override @SuppressWarnings({ "unchecked" }) public Collection<T> getChildren(Object itemId) { List<T> newChildren = children.compute...
### Question: LinkkiInMemoryContainer extends com.vaadin.v7.data.util.AbstractInMemoryContainer<T, Object, com.vaadin.v7.data.Item> implements com.vaadin.v7.data.Container.Hierarchical { @CheckForNull @Override public T getParent(Object itemId) { return parents.get(itemId); } @Override Collection<?> getContainerProper...