001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.apache.commons.numbers.field;
018
019import org.apache.commons.numbers.core.NativeOperators;
020
021/**
022 * Boiler-plate code for concrete implementations of {@link Field}.
023 *
024 * @param <T> Type of the field elements.
025 */
026public abstract class AbstractField<T extends NativeOperators<T>>
027    implements Field<T> {
028    /** Create an instance. */
029    public AbstractField() {}
030
031    /** {@inheritDoc} */
032    @Override
033    public T add(T a, T b) {
034        return a.add(b);
035    }
036
037    /** {@inheritDoc} */
038    @Override
039    public T subtract(T a, T b) {
040        return a.subtract(b);
041    }
042
043    /** {@inheritDoc} */
044    @Override
045    public T negate(T a) {
046        return a.negate();
047    }
048
049    /** {@inheritDoc} */
050    @Override
051    public T multiply(int n, T a) {
052        return a.multiply(n);
053    }
054
055    /** {@inheritDoc} */
056    @Override
057    public T multiply(T a, T b) {
058        return a.multiply(b);
059    }
060
061    /** {@inheritDoc} */
062    @Override
063    public T divide(T a, T b) {
064        return a.divide(b);
065    }
066
067    /** {@inheritDoc} */
068    @Override
069    public T reciprocal(T a) {
070        return a.reciprocal();
071    }
072}