/** * Checks whether precompressed Brotli files should be used if available. * * @return <code>true</code> to serve precompressed Brotli files, * <code>false</code> to not serve Brotli files. */ default boolean isBrotli() { return getBooleanProperty(Constants.SERVLET_PARAMETER_BROTLI, false); } }
@Override public Object getId(T item) { Object itemId = idGetter.apply(item); assert itemId != null : "CallbackDataProvider got null as an id for item: " + item; return itemId; } }
/** * Determines if webJars mechanism is enabled. It is disabled if the user * have explicitly set the {@link Constants#DISABLE_WEBJARS} property to * {@code true}, or the user have not set the property at all and the * {@link #useCompiledFrontendResources()} returns false. * * @return {@code true} if webJars are enabled, {@code false} otherwise */ default boolean areWebJarsEnabled() { return !getBooleanProperty(Constants.DISABLE_WEBJARS, useCompiledFrontendResources()); }
/** * Creates a new predicate from the given predicate and value provider. This * allows using a predicate of the value providers return type with objects * of the value providers type. * * @param valueProvider * the value provider to use * @param valueFilter * the original predicate * @param <T> * the data provider object type * @param <V> * the provided value type * * @return the created predicate */ public static <T, V> SerializablePredicate<T> createValueProviderFilter( ValueProvider<T, V> valueProvider, SerializablePredicate<V> valueFilter) { return item -> valueFilter.test(valueProvider.apply(item)); }
@Override public void execute() { command.accept(getUI()); removeAttachListener(this); } });
/** * Creates a component for a given object model item. Subclasses can * override this method to provide specific behavior. * * @param item * the model item, possibly <code>null</code> * @return a component instance representing the provided item */ public COMPONENT createComponent(SOURCE item) { if (componentFunction != null) { return componentFunction.apply(item); } COMPONENT component = componentSupplier.get(); if (itemConsumer != null) { itemConsumer.accept(component, item); } return component; }
@Override default SerializablePredicate<T> negate() { return t -> !test(t); }
@Override public P convertToPresentation(M value, ValueContext context) { return toPresentation.apply(value); } };
/** * Gets the URL from which frontend resources should be loaded in ES6 * compatible browsers. * * @return the ES6 resource URL */ default String getEs6FrontendPrefix() { return useCompiledFrontendResources() ? getStringProperty(Constants.FRONTEND_URL_ES6, Constants.FRONTEND_URL_ES6_DEFAULT_VALUE) : getDevelopmentFrontendPrefix(); }
@SuppressWarnings("unchecked") @Override protected void setPresentationValue(T newPresentationValue) { propertyWriter.accept((C) this, newPresentationValue); }
/** * Determines if Flow should use compiled or original frontend resources. * * User can explicitly disable bundled resources usage by setting the * {@link Constants#USE_ORIGINAL_FRONTEND_RESOURCES} property to * {@code true}. * * @return {@code true} if Flow should use compiled frontend resources. */ default boolean useCompiledFrontendResources() { return isProductionMode() && !getBooleanProperty( Constants.USE_ORIGINAL_FRONTEND_RESOURCES, false); }
private void updateChildren() { contentReset.run(); }
/** * Create a response writer with the given deployment configuration. * * @param deploymentConfiguration * the deployment configuration to use, not <code>null</code> */ public ResponseWriter(DeploymentConfiguration deploymentConfiguration) { this(DEFAULT_BUFFER_SIZE, deploymentConfiguration.isBrotli()); }
private boolean applyValue(T value) { presentationUpdateInProgress = true; /* * Toggled to true by setModelValue if that method is run while * presentationUpdateInProgress is also true. */ valueSetFromPresentationUpdate = false; try { setPresentationValue.accept(value); } finally { presentationUpdateInProgress = false; } return valueSetFromPresentationUpdate; } }
private boolean isItemEnabled(T item) { return itemEnabledProvider == null || itemEnabledProvider.test(item); }
@Override public Result<M> convertToModel(P value, ValueContext context) { return toModel.apply(value); }
@Override protected String getItemKey(T item) { if (keyMapper == null) { return null; } return keyMapper.apply(item); }
/** * Gets the URL from which frontend resources should be loaded in ES5 * compatible browsers. * * @return the ES5 resource URL */ default String getEs5FrontendPrefix() { return useCompiledFrontendResources() ? getStringProperty(Constants.FRONTEND_URL_ES5, Constants.FRONTEND_URL_ES5_DEFAULT_VALUE) : getDevelopmentFrontendPrefix(); }
/** * Determines if Flow should automatically register servlets. For more * information on the servlets registered, refer to * {@link com.vaadin.flow.server.startup.ServletDeployer} javadoc. * * User can explicitly disable automatic servlet registration by setting the * {@link Constants#DISABLE_AUTOMATIC_SERVLET_REGISTRATION} property to * {@code true}. * * @return {@code true} if Flow should not automatically register servlets * @see com.vaadin.flow.server.startup.ServletDeployer */ default boolean disableAutomaticServletRegistration() { return getBooleanProperty( Constants.DISABLE_AUTOMATIC_SERVLET_REGISTRATION, false); }
/** * Returns the error message for the given value. * * @param value * an invalid value * @return the formatted error message */ protected String getMessage(T value) { return messageProvider.apply(value); }