001/*
002 * Units of Measurement TCK
003 * Copyright © 2005-2017, Jean-Marie Dautelle, Werner Keil, V2COM.
004 *
005 * All rights reserved.
006 *
007 * Redistribution and use in source and binary forms, with or without modification,
008 * are permitted provided that the following conditions are met:
009 *
010 * 1. Redistributions of source code must retain the above copyright notice,
011 *    this list of conditions and the following disclaimer.
012 *
013 * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
014 *    and the following disclaimer in the documentation and/or other materials provided with the distribution.
015 *
016 * 3. Neither the name of JSR-385 nor the names of its contributors may be used to endorse or promote products
017 *    derived from this software without specific prior written permission.
018 *
019 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
020 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
021 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
022 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
023 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
024 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
025 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
026 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
027 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
028 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
029 */
030package tech.units.tck.util;
031
032import javax.measure.Dimension;
033import javax.measure.Quantity;
034import javax.measure.Unit;
035import javax.measure.UnitConverter;
036import javax.measure.format.UnitFormat;
037
038import java.util.Collection;
039import java.util.ServiceLoader;
040
041/**
042 * Libraries that implement this JSR and want to be tested with this TCK must implement this
043 * interface and register it using the {@link ServiceLoader}.
044 *
045 * @author Werner Keil
046 * @version 1.0.1, Sep 10, 2017
047 * @since 1.0
048 */
049public interface ServiceConfiguration{
050
051    /**
052     * Return a collection with all {@link Quantity} classes that are implemented. The list
053     * must not be empty and should contain <b>every</b> quantity class implemented.<p>
054     * This enables the TCK to check in addition to the basic implementation compliance, if
055     * according {@link ServiceProvider} is registered/available.
056     *
057     * @return a collection with all implemented amount classes, not null.
058     */
059    @SuppressWarnings("rawtypes")
060    Collection<Class> getQuantityClasses();
061    
062    /**
063     * List a collection of {@link Unit} implementations.<p>
064     * This enables the TCK to check the basic implementation compliance.
065     *
066     * @return a collection with Unit implementations to be tested.
067     */
068    @SuppressWarnings("rawtypes")
069    Collection<Class> getUnitClasses();
070    
071    /**
072     * List a collection of {@link Dimension} implementations.<p>
073     * This enables the TCK to check the basic implementation compliance.
074     *
075     * @return a collection with {@link Dimension} implementations to be tested.
076     */
077    @SuppressWarnings("rawtypes")
078    Collection<Class> getDimensionClasses();
079    
080    /**
081     * List a collection of {@link Prefix} implementations.<p>
082     * This enables the TCK to check the basic implementation compliance.
083     *
084     * @return a collection with {@link Prefix} implementations to be tested.
085     * @since 2.0
086     */
087    @SuppressWarnings("rawtypes")
088    Collection<Class> getPrefixClasses();
089    // Although this is already given by the API it allows to check for additional implementations
090    
091    /**
092     * Return a collection with all supported {@link Quantity} types. The list
093     * must not return <tt>null</tt>, but could be empty in certain profiles.
094     * 
095     * @return the list of quantity types to be checked, not <tt>null</tt>. It is allowed to return an empty list here, which will
096     *
097     * @return a collection with all implemented amount classes, not null.
098     */
099    @SuppressWarnings("rawtypes")
100    Collection<Class<? extends Quantity>> getSupportedQuantityTypes();
101    
102    /**
103     * Returns a matching unit for the specified quantity type.
104     * This is a "helper method" to avoid direct references to {@link SystemOfUnits} or implementations in profiles without SPI.
105     * 
106     * @param <Q>
107     *            the compile-time quantity type.
108     * @param quantityType
109     *            the quantity type.
110     * @return the unit for the specified quantity.
111     */
112    public <Q extends Quantity<Q>> Unit<Q> getUnit4Type(Class<Q> quantityType);
113
114    /**
115     * This method allows instances of Unit to be tested for requirements and recommendations.
116     *
117     * @return the list of units to be checked, not null. It is allowed to return an empty list here, which will
118     * disable certain TCK tests, e.g. if the result isn't needed by a particular profile.
119     */
120    Collection<? extends Unit<?>> getUnits4Test();
121    
122    /**
123     * This method returns the base dimensions to be tested for requirements and recommendations.
124     *
125     * @return the list of base dimensions to be checked, not null. It is allowed to return an empty list here, which will
126     * disable certain TCK tests, e.g. if the result isn't needed by a particular profile.
127     */
128    Collection<Dimension> getBaseDimensions();
129
130    /**
131     * This method allows instances of UnitConverter to be tested for requirements and recommendations.
132     *
133     * @return the list of unit converters to be checked, not null. It is allowed to return an empty list here, which will
134     * disable TCK tests for UnitConverter instances.
135     */
136    Collection<UnitConverter> getUnitConverters4Test();
137    
138    /**
139     * This method allows instances of UnitFormat to be tested for requirements and recommendations.
140     *
141     * @return the list of unit converters to be checked, not null. It is allowed to return an empty list here, which will
142     * disable certain TCK tests, e.g. if the result isn't needed by a particular profile.
143     */
144    Collection<UnitFormat> getUnitFormats4Test();
145}