Giter Club home page Giter Club logo

silver's Introduction

Silver

Build Status

Have you ever wanted a set of all classes that implemented a certain interface? How about all classes annotated with a given annotation? Silver gives you this capability. Silver is an annotation processor that collects classes in your project based on a set of rules. Simply annotate an interface with @Silver that includes no-argument methods returning Set<Class>. Annotate these methods with Silver rules like @AnnotatedBy, @Inherits or @Package and then compile with Silver on the classpath. Silver will implement the class and make it available via the SilverUtil class.

Example

@Silver
public interface Example {
   @AnnotatedBy(ExampleAnnotation.class)
   Set<Class<?>> getAnnotated();

   @Inherits(Base.class)
   Set<Class<?>> getExtendsBase();

   @Inherits(Base.class)
   @AnnotatedBy(TestAnnotation.class)
   Set<Class<?>> getAnnotatedExtendsBase();

   @Package("org.example")
   Set<Class<?>> getExamplePackageClasses();
}

public @interface ExampleAnnotation {}
public interface Base{}

public class One implements Base{}

@ExampleAnnotation
public class Two implements Base{}

@ExampleAnnotation
public class Three{}

SilverUtil.get(Example.class).getAnnotated(); // Returns Two.class, Three.class
SilverUtil.get(Example.class).getExtendsBase(); // Returns One.class, Two.class
SilverUtil.get(Example.class).getAnnotatedExtendsBase(); // Returns Two.class
Silverutil.get(Example.class).getExamplePackageClasses(); // Returns classes under org.example

Getting Silver

Compile and install Silver into your local Maven repository:

git clone https://github.com/johncarl81/silver.git
cd silver
mvn clean install;

Then reference in your project:

<dependency>
    <groupId>org.silver</groupId>
    <artifactId>silver</artifactId>
    <version>${silver.version}</version>
    <scope>provided</scope>
</dependency>
<dependency>
    <groupId>org.silver</groupId>
    <artifactId>silver-api</artifactId>
    <version>${silver.version}</version>
</dependency>

License

Copyright 2014-2015 John Ericksen

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

silver's People

Contributors

johncarl81 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.