ミスターヴァンダービルト:
開発中に、私はまだ実験的な地位を持って、時には書き込みクラスやメソッド。私は、コード内で直接それらを見ることができるように、これらのクラスを宣言したいと思います。全体のものは次のように動作するはずです@Deprecated
。唯一の反対の意味を持ちます。
私の知る限りでは、Javaではそのような宣言がありません。またはそれは?そうでない場合:どのように私は、この機能を実現するだろうか?
Mchwkr:
ジャワ1.6+(ないように注意してください1.5程度)を使用すると、独自のカスタムアノテーションを使用することができるために、ここで使用できる機能テンプレートは以下のとおりです。
package com.mycompany.annotations;
import java.lang.annotation.*;
/**
*
* This element has an experimental maturity. Use with caution.
*
*
* NOTE: The developers of this element is not responsible for the issues created,
* using it is not suggested for production environment. If you see this annotation do this, do not do that etc
* Enjoy responsibly....
*/
@Documented //this annotation maybe helpful for your custom annotation
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE, ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER,
ElementType.CONSTRUCTOR, ElementType.LOCAL_VARIABLE, ElementType.PACKAGE,
ElementType.ANNOTATION_TYPE, ElementType.TYPE_USE, ElementType.TYPE_PARAMETER
})
public @interface Experimental {}
ここでのソースコードは、ElementType
誰もが要素を使用したくない場合がありますので、ElementType.TYPE_USE, ElementType.TYPE_PARAMETER
/*
....
* @since 1.5
* @jls 9.6.4.1 @Target
* @jls 4.1 The Kinds of Types and Values
*/
public enum ElementType {
/** Class, interface (including annotation type), or enum declaration */
TYPE,
/** Field declaration (includes enum constants) */
FIELD,
/** Method declaration */
METHOD,
/** Formal parameter declaration */
PARAMETER,
/** Constructor declaration */
CONSTRUCTOR,
/** Local variable declaration */
LOCAL_VARIABLE,
/** Annotation type declaration */
ANNOTATION_TYPE,
/** Package declaration */
PACKAGE,
/**
* Type parameter declaration
*
* @since 1.8
*/
TYPE_PARAMETER,
/**
* Use of a type
*
* @since 1.8
*/
TYPE_USE
}
ちなみにこれは、私はおそらく実験を実施したライブラリを検索するとき、私は私のIntelliJから見たものです
あるExperimental
Javaの9で定義された注釈は、しかし、それはOracleのJDK、OpenJDKがないのいずれかであることに注意してください。この記事の時点で、あなたはそれを使用する/確認するために公式サイトからJDK-11をインストールする必要があります。ため、私はスティーブンC.が記載されている事実を、この目的のためにそれを使用することはありません。
あなたはとにかくメソッドのためにそれを使用することはできません。そのソースコードがあるので、
...
package jdk.jfr;
/*
...
*
* @since 9
*/
@MetadataDefinition
@Label("Experimental")
@Description("Element is not to be shown to a user by default")
@Inherited
@Retention(RetentionPolicy.RUNTIME)
@Target({ ElementType.FIELD, ElementType.TYPE })
public @interface Experimental {
}