📜 ⬆️ ⬇️

Google Annotations Gallery

The Google Annotations Gallery is a new open-source library that provides ample opportunities for programmers to express themselves. You do not find that standard Java annotations are dry and lifeless? You didn't want to annotate LOL or Facepalm ( ? ) Then, this gallery is for you.

Source code: code.google.com/p/gag

Annotation Description


@AnimalsHarmedDuringTheMaking

Abstract @AnimalsHarmedDuringTheMaking allows you to uncover the facts about animal abuse.
Copy Source | Copy HTML @AnimalsHarmedDuringTheMaking( number = 1 , animal = "" , disclosure = " Fermie 2 " ) public class ConstantTimePrimalityTest {
  1. Copy Source | Copy HTML @AnimalsHarmedDuringTheMaking( number = 1 , animal = "" , disclosure = " Fermie 2 " ) public class ConstantTimePrimalityTest {
  2. Copy Source | Copy HTML @AnimalsHarmedDuringTheMaking( number = 1 , animal = "" , disclosure = " Fermie 2 " ) public class ConstantTimePrimalityTest {
  3. Copy Source | Copy HTML @AnimalsHarmedDuringTheMaking( number = 1 , animal = "" , disclosure = " Fermie 2 " ) public class ConstantTimePrimalityTest {
  4. Copy Source | Copy HTML @AnimalsHarmedDuringTheMaking( number = 1 , animal = "" , disclosure = " Fermie 2 " ) public class ConstantTimePrimalityTest {
  5. Copy Source | Copy HTML @AnimalsHarmedDuringTheMaking( number = 1 , animal = "" , disclosure = " Fermie 2 " ) public class ConstantTimePrimalityTest {


@CarbonFootprint

For environmentally conscious developers, this annotation indicates the carbon footprint that code execution causes. Measured in CO2Units.
Copy Source | Copy HTML
  1. @CarbonFootprint (
  2. value = 6 . 28318531 ,
  3. units = GRAMS_PER_MEGAJOULE)
  4. public interface Holodeck {

@ProbablyIllegalIn

What if your code is illegal in some states?
Copy Source | Copy HTML
  1. @ProbablyIllegalIn (number = 17, region = STATES)
  2. public Money extractFractionalPennies (Account account);

')
@WrittenWhile

It so happens that you are not in the best shape. May be distracted by something. Then this is for you.
Copy Source | Copy HTML
  1. @WrittenWhile ( "surfing chatroulette" )
  2. public interface You {
  3. void spin Right Round; Right Round ( Me me );
  4. }

@ThisHadBetterBe and @ThisHadBetterNotBe

These annotations are useful to show that you are not ready for some meanings.
Copy Source | Copy HTML
  1. public void setBonusMultiplier ( @ThisHadBetterNotBe (NEGATIVE ) double multiplier) {
  2. this.multiplier = multiplier ;
  3. }
  4. public void misappropriate ( @ThisHadBetterBe (THE_STOLEN_DEATH_STAR_PLANS ) DataTape tape) {
  5. r2.record ( tape.play ( ));
  6. ship.getEscapePod (). insert ( r2 ) .jettison ();
  7. }

Noop

Want to turn off the method? or a whole class? Why use // and / * * /? Use Noop and that's it! More method is not executed.
Copy Source | Copy HTML
  1. public class FluxCapacitor {
  2. @Noop ( "see how long it will be before Emmett realizes that he no longer travels in time" )
  3. public void setDate ( Date date ) {
  4. this.date = date ;
  5. }
  6. public void setSpeed ​​( int speed ) {
  7. this.speed = speed ;
  8. }

@Roulette

Want to remind customers of politeness? Add @Roulette, and watch how the method throws exceptions with a given probability
Copy Source | Copy HTML
  1. @Roulette (
  2. probability = 0 . 005 ,
  3. exception = PayYourContractorException,
  4. message = "Courtesy reminder" )
  5. public Service getRockSolidService () {


Literary annotations


Copy Source | Copy HTML
  1. @Alliteration
  2. Peck pickledPeppers = peterPiper.pick ();
  3. @Haiku
  4. public void checkNodes () {
  5. if ( tree.hasAnyLeafNodes ( )) {
  6. freshenLeavesOn ( tree );
  7. }
  8. }
  9. @HapaxLegomenon
  10. public interface Honorificabilitudinitatibus {
  11. void achieve ( Honor honor );
  12. }
  13. @Metaphor
  14. public interface Life extends Box <Chocolate> {
  15. }
  16. @ Meter ( TROCHAIC )
  17. public abstract double axisOffset ();
  18. @Oxymoron
  19. public interface DisassemblerFactory {
  20. Disassembler createDisassembler ();
  21. }
  22. @Palindrome
  23. Event e = gala.get ( n, EVE );
  24. @Synecdoche
  25. Network fiber = NetworkFactory.createNetwork ();

Notes


Javadocs comments - who reads them? Annotations are much more fashionable. No one can get past @OhSnap or WTF .
Add during code review:
Copy Source | Copy HTML
  1. @LOL @Facepalm
  2. @WTF ("just use Collections.reverse ()")
  3. @Booyah
  4. private static < T > void invertOrdering (List < T > list) {
  5. for (int i = 0; i < list.size () / 2; i ++) {
  6. int j = list.size () - 1 - i;
  7. T item1 = list.get (i);
  8. T item2 = list.get (j);
  9. list.set (i, item2);
  10. list.set (j, item1);
  11. }
  12. }

Need a quote? Use @ObligatoryQuote:
Copy Source | Copy HTML
  1. @ObligatoryQuote (
  2. quote = "Remember, raptors run at 10 m / s and they do n't know fear."
  3. source = Source.XKCD,
  4. citation = "http://xkcd.com/135/")
  5. public Route planRoute (FloorPlan floorPlan, Set <Velociraptor> raptors);

Life is short. Use Magic for complex code and move on:
Copy Source | Copy HTML
  1. @Magic
  2. public static int negate ( int n ) {
  3. return new Byte ( (byte ) 0xFF) .hashCode ()
  4. / ( int ) ( short ) '\ uFFFF' * ~ 0
  5. * Character.digit ( '0', 0 ) * n
  6. * ( Integer.MAX_VALUE * 2 + 1 )
  7. / ( Byte.MIN_VALUE >> 7 ) * ( ~ 1 | 1 );
  8. }

Want to complain Jav? You are welcome:
Copy Source | Copy HTML
  1. @ThisWouldBeOneLineIn (<br/> language = "haskell" <br/> toWit = "product [1..n]" )
  2. public int factorial ( int n ) {
  3. int fac = 1 ;
  4. for ( int i = 1; i <= n; i ++ ) {
  5. fac * = i ;
  6. }
  7. return fac;
  8. }

Source: https://habr.com/ru/post/89647/


All Articles