All Downloads are FREE. Search and download functionalities are using the official Maven repository.

sirius.kernel.di.transformers.Transformer Maven / Gradle / Ivy

/*
 * Made with all the love in the world
 * by scireum in Remshalden, Germany
 *
 * Copyright by scireum GmbH
 * http://www.scireum.de - [email protected]
 */

package sirius.kernel.di.transformers;

import sirius.kernel.di.std.Priorized;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;

/**
 * Transforms a Transformable into a given target type.
 * 

* Used by {@link Transformers} to transform a certain type into another one. This * permits to transform existing classes into interfaces or other classes without modifying them. * * @param the source type which is supported as input of the transformation * @param the target type which is supported as output of the transformation */ public interface Transformer extends Priorized { /** * As multiple adapters for the same pair of types might be present, the priority is used to specify precedence. * * @return the priority (lower is better) of this transformer */ @Override default int getPriority() { return Priorized.DEFAULT_PRIORITY; } /** * Returns the source type for which this factory can perform transformations. * * @return the source type for which transformations are supported. */ Class getSourceClass(); /** * Returns the target type for which this factory can perform transformations. * * @return the target type for which transformations are supported. */ Class getTargetClass(); /** * Generates a new object of the desired target type for the given object to transform. * * @param source the object to transform * @return the transformed instance (matching the target class) or null to indicate that no conversion * was possible. */ @Nullable T make(@Nonnull S source); }