diff --git a/src/main/java/osc/git/eh3/annotation/PkgAnnotation.java b/src/main/java/osc/git/eh3/annotation/PkgAnnotation.java new file mode 100644 index 0000000..b1d8799 --- /dev/null +++ b/src/main/java/osc/git/eh3/annotation/PkgAnnotation.java @@ -0,0 +1,19 @@ +/** + * + */ +package osc.git.eh3.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * @author lixiangrong + * + */ +@Target(ElementType.PACKAGE) +@Retention(RetentionPolicy.RUNTIME) +@interface PkgAnnotation { + +} diff --git a/src/main/java/osc/git/eh3/annotation/TestPkgAnnotation.java b/src/main/java/osc/git/eh3/annotation/TestPkgAnnotation.java new file mode 100644 index 0000000..0285418 --- /dev/null +++ b/src/main/java/osc/git/eh3/annotation/TestPkgAnnotation.java @@ -0,0 +1,18 @@ +package osc.git.eh3.annotation; + +import java.lang.annotation.Annotation; + +public class TestPkgAnnotation { + + public static void main(String[] args) { + Package pkg = Package.getPackage("osc.git.eh3.annotation"); + Annotation[] annotations = pkg.getAnnotations(); + for (Annotation annotation : annotations) { + System.out.println(annotation); + } + + // ===========================友好类和包内访问常量============== + new MyPackageMethod().myPackageMethod(); + System.out.println(MyPackageConst.PACKAGE_STRING); + } +} diff --git a/src/main/java/osc/git/eh3/annotation/package-info.java b/src/main/java/osc/git/eh3/annotation/package-info.java new file mode 100644 index 0000000..8416033 --- /dev/null +++ b/src/main/java/osc/git/eh3/annotation/package-info.java @@ -0,0 +1,25 @@ +/** + * + */ +/** + * @author lixiangrong + * + */ +@PkgAnnotation +package osc.git.eh3.annotation; + +/** + * 包内方法 + */ +class MyPackageMethod { + public void myPackageMethod() { + System.out.println("MyPackageMethod..."); + } +} + +/** + * 包内常量 + */ +class MyPackageConst { + static final java.lang.String PACKAGE_STRING = "myPackageConst"; +} \ No newline at end of file diff --git a/src/main/resources/generatorConfig.xml b/src/main/resources/generatorConfig.xml new file mode 100644 index 0000000..92a4ab0 --- /dev/null +++ b/src/main/resources/generatorConfig.xml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +
\ No newline at end of file