Java “错误”;无法降低继承方法的可见性";在实现接口时

Java “错误”;无法降低继承方法的可见性";在实现接口时,java,inheritance,interface,subclass,Java,Inheritance,Interface,Subclass,我刚刚安装了泰姬陵技术分析库。 它有一个名为TimeSeries的接口类。 当我尝试在TimeSeries String getName() 我得到以下错误: 无法降低TimeSeries中固有方法的可视性 implaments org.ta4jcore.Timeserios.GetName 我的代码 import org.ta4j.core.*; public class cMyChartVal implements TimeSeries { /** * @ret

我刚刚安装了泰姬陵技术分析库。 它有一个名为
TimeSeries
的接口类。 当我尝试在
TimeSeries

String getName()

我得到以下错误:

无法降低TimeSeries中固有方法的可视性 implaments org.ta4jcore.Timeserios.GetName

我的代码

import org.ta4j.core.*;



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

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);
}
package org.ta4j.core;
导入java.io.Serializable;
导入java.time.format.DateTimeFormatter;
导入java.util.List;
/**
*{@link Bar}序列由预定义的时间段分隔(例如15分钟、1天等)
*

*值得注意的是,{@link TimeSeries time series}可以是: *
    *
  • 计算{@link Indicator}的基础 *
  • 限制在开始索引和结束索引之间(例如,对于某些回溯测试案例) *
  • 限于固定数量的条(例如,用于实际交易) *
*/ 公共接口TimeSeries扩展了可序列化{ /** *@返回序列的名称 */ 字符串getName(); /** *@param i是一个索引 *@将杆返回到第i个位置 */ Bar getBar(int i); /** *@返回序列的第一个条 */ 默认栏getFirstBar(){ 返回getBar(getBeginIndex()); } /** *@返回系列的最后一条 */ 默认栏getLastBar(){ 返回getBar(getEndIndex()); } /** *@返回序列中的条数 */ int getBarCount(); /** *@如果序列为空,则返回true,否则返回false */ 默认布尔值为空(){ 返回getBarCount()==0; } /** *警告:应小心使用! * *返回原始条形图数据。 *这意味着它返回当前列表对象,该对象在内部用于存储{@linkbar}。 *它可能是: *-如果设置了最大条数,则缩短条列表 *-如果是受约束的时间序列,则为扩展条形图列表 *@返回原始条数据 */ 列出getBarData(); /** *@返回序列的开始索引 */ int getBeginIndex(); /** *@返回序列的结束索引 */ int getEndIndex(); /** *@返回系列期间的描述(例如“从2014年1月21日12:00至2014年1月21日12:15”) */ 默认字符串getSeriesPeriodDescription(){ StringBuilder sb=新的StringBuilder(); 如果(!getBarData().isEmpty()){ Bar firstBar=getFirstBar(); Bar lastBar=getLastBar(); sb.append(firstBar.getEndTime()格式(DateTimeFormatter.ISO_DATE_TIME)) .附加(“—”) .append(lastBar.getEndTime().format(DateTimeFormatter.ISO_DATE_TIME)); } 使某人返回字符串(); } /** *设置将保留在系列中的最大条数。 * *如果向系列中添加了一个新条,使条数超过最大条数, *然后,自动移除系列中的第一根棒,确保不超过最大棒数。 *@param maximumBarCount最大条数 */ void setMaximumBarCount(int maximumBarCount); /** *@返回最大条数 */ int getMaximumBarCount(); /** *@返回移除的条数 */ int getRemovedBarsCount(); /** *在系列末尾添加一个条形图。 * *如果未初始化,则开始索引设置为0。
*如果未初始化,则结束索引设置为0;如果与系列结尾匹配,则增加索引。
*超过的钢筋被移除。 *@param bar要添加的条 *@see TimeSeries#setMaximumBarCount(int) */ void addBar(Bar-Bar); /** *返回作为此TimeSeries实现子集的新TimeSeries实现。 *它保存startIndex(包含)和endIndex(独占)之间所有{@link Bar}的副本 *这个时间序列的一部分。 *此时间序列和新子集时间序列的索引可以不同。即,新时间序列的索引0将不同 *是此时间序列的索引startIndex。 *如果startIndexthis.SeriesIndex,则新的时间序列将在此时间序列的最后一个可用条结束 *@param startIndex startIndex *@param endIndex endIndex *@返回从startIndex到endIndex-1的带条的新BaseTimeSeries *@抛出IllegalArgumentException,例如如果endIndex
接口中的所有方法声明(包括静态方法)都是隐式公开的。它通常被省略

实现类应该保留此修改器,而不是使用默认的类方法修改器(
包级别

您可以将其更改为:

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

实际上,接口中的所有方法都是隐式公共的。不是真正的“默认修饰符”,因为这意味着还有其他非默认的有效标识符。