Skip to content
Ali Al-Ramadan edited this page Nov 14, 2026 · 2 revisions

The rules of the method stereotypes, the free-function stereotypes, and the class stereotypes hold in Java as in every language of Stereocode. This page gives the forms that the facts of these rules take in Java, the built-in lists that Stereocode reads for Java, and one labeled example of each stereotype. The section Data Members and Calls states in full how Stereocode reads data members, types, returned values, and calls in Java.

Language Facts

  • A method reaches its object through this. A member class without static counts the data members of its enclosing instances as its own, while Outer.this names the enclosing instance of the class Outer.
  • A parameter of a type that is not primitive shares its object with the caller, as does a variadic parameter such as int... out.
  • Each component of a record has an accessor of its name. Each method of the body of an enum constant counts as a method of the enum.
  • Inside a local or an anonymous class, this and super name the object of that class. new Runnable() { } creates an object.
  • A call without an object to a method that no type of the archive defines is a call to the object itself when its name is an accessor of Object with its number of arguments, namely equals, hashCode, toString, getClass, or clone. The same holds when the class has a parent outside the archive.
  • Interfaces and enums get their stereotypes with the options -i and -e.

Built-in Lists

Stereocode reads four built-in lists for Java. The list files of the options -p, -c, -s, and -q add entries to these lists under the section [Java], as the README states. Each list below opens with a click.

Primitive types (19 entries)

A type of this list makes no method a collaborator and no return type of a factory.

Boolean, boolean, Byte, byte, char, Character, Double, double, Float, float, int, Integer, Long, long, Short, short, String, Void, void

Ignored calls (5 entries)

The rules ignore a call of these names, also after a qualifier, as std::exit for exit and System.Console.WriteLine for Console.WriteLine.

System.err.println, System.exit, System.out.print, System.out.printf, System.out.println

Specifiers and containers (44 entries)

Stereocode strips these entries from a written type before it reads the names of the type. A container counts by the types of its elements. Each entry is a regular expression, such as \.\.\. for ....

<, >, @\w+, \.\.\., \?, abstract, ArrayDeque, ArrayList, Collection, default, Deque, EnumMap, EnumSet, extends, final, HashMap, HashSet, Hashtable, Iterable, Iterator, LinkedHashMap, LinkedHashSet, LinkedList, List, Map, native, PriorityQueue, private, protected, public, Queue, Set, SortedMap, SortedSet, Stack, static, strictfp, super, synchronized, transient, TreeMap, TreeSet, Vector, volatile

Query methods (10 entries)

A call of these methods only reads the variable that the call is on.

contains, containsKey, equals, get, getClass, hashCode, isEmpty, length, size, toString

Examples

Each example below is the declaration of an element from the stereotype cases of Stereocode, whose expected stereotypes are written by hand in @stereotype comments. Each link opens the case on the branch develop. The second column gives every stereotype of the element. A stereotype without an example has no case in Java.

Methods

Stereotype Stereotypes of the element Declaration
get get public double getCelsius() { return celsius; }
predicate predicate boolean isZero(int i) { return arr[i] == 0; }
property property double offset() { return fahrenheit() - 32; }
void-accessor void-accessor void dequantize(int[] dataUnit, int iComp)
set set void level(double value) { degrees = value; }
command command void fill() { level = capacity; capacity++; }
non-void-command non-void-command default int twice() { return area() * 2; }
factory factory collaborator stateless default Widget make() { return new Widget(); }
collaborator property collaborator int scaled(Scale scale) { return value * 2; }
controller controller void paint(Widget widget) { widget.poke(level); }
wrapper wrapper void copyToPart() { Store.shared().b = b; }
incidental incidental void warn(int v) { System.err.println(v); }
stateless controller stateless void run() { Flowable.just(1).subscribe(); }
empty empty public void close() { /* nothing to release */ }
constructor constructor protected Shape(int count) { sides = count; }
copy-constructor copy-constructor Vertex(Vertex other) { kind = other.kind; }
destructor No case
unclassified unclassified void print() { System.out.println(count); }

TABLE 1. Examples of the method stereotypes in Java.

Free functions

Stereotype Stereotypes of the element Declaration
main main public static void main(String[] args) { report(args.length); }
predicate predicate public static boolean isEven(int value) { return value % 2 == 0; }
property property static int twice(int value) { return 2 * value; }
global-command global-command static void reset() { shown = 0; }
command command static void paramCStyle(int a[]) { a[0] = 1; }
factory property factory static Stack create(int start) { Stack made = new Stack(start); return made; }
literal literal public static int answer() { return 42; }
wrapper wrapper static void show() { Journal.write(NAME); }
empty empty public static void noop(int value) { }
unclassified unclassified public static void print(int value) { System.out.println(value); }

TABLE 2. Examples of the free-function stereotypes in Java, which the option -f assigns.

Types

Stereotype Stereotypes of the element Declaration
boundary boundary class Exporter
commander commander small-interface interface Shape
controller controller class Spooler
data-class data-class class Pair
data-enum data-provider data-enum small-enum enum Level
data-interface data-provider data-interface small-interface interface Chain
data-provider data-provider class Circle
data-record data-provider data-record small-record record Size(int width)
degenerate degenerate small-record record Pair(int left, int right)
empty empty class Tag
entity entity boundary class Measure
factory factory controller class WidgetFactory
large-class large-class class Box
large-enum large-enum enum Mode
large-interface large-interface interface Shape
large-record large-record record Track(int width, java.util.List<String> items)
lazy-class lazy-class class Settings
lazy-enum lazy-enum enum Phase
lazy-interface data-provider lazy-interface interface Lazy
lazy-record data-provider lazy-record small-record record Trail(int length)
minimal-entity minimal-entity commander class Counter
pure-controller pure-controller class Dispatcher
small-class small-class class Clock
small-enum data-provider small-enum enum Mode { ON, OFF;
small-interface degenerate small-interface interface Visitor
small-record data-provider small-record record Pair(int left, int right)
unclassified unclassified class Large22

TABLE 3. Examples of the class stereotypes in Java, where large-class, lazy-class, data-class, and small-class of a type of another kind take that kind in place of class, such as data-struct.

Clone this wiki locally