Error "Cannot reduce the visibility of a inherited method" while implementing interface

Ted pottel :

I just installed the ta4j Technical Analysis lib . It has a interface class called TimeSeries. When I try to implement the first method in TimeSeries

String getName()

I get the following error:

Cannot reduce the visabilty of a inhearted methed from TimeSeries implaments org.ta4jcore.Timeserios.GetName

My Code

import org.ta4j.core.*;



public class cMyChartVal implements TimeSeries {
       /**
     * @return the name of the series
     */
    String getName()
    {
        return "TestSet";
    }
    .....
    .....
}

TimeSeries interface class

package org.ta4j.core;

import java.io.Serializable;
import java.time.format.DateTimeFormatter;
import java.util.List;

/**
 * Sequence of {@link Bar bars} separated by a predefined period (e.g. 15 minutes, 1 day, etc.)
 * </p>
 * Notably, a {@link TimeSeries time series} can be:
 * <ul>
 *     <li>the base of {@link Indicator indicator} calculations
 *     <li>constrained between begin and end indexes (e.g. for some backtesting cases)
 *     <li>limited to a fixed number of bars (e.g. for actual trading)
 * </ul>
 */
public interface TimeSeries extends Serializable {

    /**
     * @return the name of the series
     */
    String getName();

    /**
     * @param i an index
     * @return the bar at the i-th position
     */
    Bar getBar(int i);

    /**
     * @return the first bar of the series
     */
    default Bar getFirstBar() {
        return getBar(getBeginIndex());
    }

    /**
     * @return the last bar of the series
     */
    default Bar getLastBar() {
        return getBar(getEndIndex());
    }

    /**
     * @return the number of bars in the series
     */
    int getBarCount();

    /**
     * @return true if the series is empty, false otherwise
     */
    default boolean isEmpty() {
        return getBarCount() == 0;
    }

    /**
     * Warning: should be used carefully!
     * <p>
     * Returns the raw bar data.
     * It means that it returns the current List object used internally to store the {@link Bar bars}.
     * It may be:
     *   - a shortened bar list if a maximum bar count has been set
     *   - a extended bar list if it is a constrained time series
     * @return the raw bar data
     */
    List<Bar> getBarData();

    /**
     * @return the begin index of the series
     */
    int getBeginIndex();

    /**
     * @return the end index of the series
     */
    int getEndIndex();

    /**
     * @return the description of the series period (e.g. "from 12:00 21/01/2014 to 12:15 21/01/2014")
     */
    default String getSeriesPeriodDescription() {
        StringBuilder sb = new StringBuilder();
        if (!getBarData().isEmpty()) {
            Bar firstBar = getFirstBar();
            Bar lastBar = getLastBar();
            sb.append(firstBar.getEndTime().format(DateTimeFormatter.ISO_DATE_TIME))
                    .append(" - ")
                    .append(lastBar.getEndTime().format(DateTimeFormatter.ISO_DATE_TIME));
        }
        return sb.toString();
    }

    /**
     * Sets the maximum number of bars that will be retained in the series.
     * <p>
     * If a new bar is added to the series such that the number of bars will exceed the maximum bar count,
     * then the FIRST bar in the series is automatically removed, ensuring that the maximum bar count is not exceeded.
     * @param maximumBarCount the maximum bar count
     */
    void setMaximumBarCount(int maximumBarCount);

    /**
     * @return the maximum number of bars
     */
    int getMaximumBarCount();

    /**
     * @return the number of removed bars
     */
    int getRemovedBarsCount();

    /**
     * Adds a bar at the end of the series.
     * <p>
     * Begin index set to 0 if if wasn't initialized.<br>
     * End index set to 0 if if wasn't initialized, or incremented if it matches the end of the series.<br>
     * Exceeding bars are removed.
     * @param bar the bar to be added
     * @see TimeSeries#setMaximumBarCount(int)
     */
    void addBar(Bar bar);

    /**
     * Returns a new TimeSeries implementation that is a subset of this TimeSeries implementation.
     * It holds a copy of all {@link Bar bars} between <tt>startIndex</tt> (inclusive) and <tt>endIndex</tt> (exclusive)
     * of this TimeSeries.
     * The indices of this TimeSeries and the new subset TimeSeries can be different. I. e. index 0 of the new TimeSeries will
     * be index <tt>startIndex</tt> of this TimeSeries.
     * If <tt>startIndex</tt> < this.seriesBeginIndex the new TimeSeries will start with the first available Bar of this TimeSeries.
     * If <tt>endIndex</tt> > this.seriesEndIndex the new TimeSeries will end at the last available Bar of this TimeSeries
     * @param startIndex the startIndex
     * @param endIndex the endIndex
     * @return a new BaseTimeSeries with Bars from startIndex to endIndex-1
     * @throws IllegalArgumentException e.g. if endIndex < startIndex
     */
    TimeSeries getSubSeries(int startIndex, int endIndex);
}
xingbin :

All method declarations in an interface, including static methods, are implicitly public. And it's usually omitted.

The implementation class should keep this modifer, instead of using default class method modifer( package level).

You can change it to:

public String getName()
{
    return "TestSet";
}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=111640&siteId=1