TypeSelector

Please see the Selectors page for a description of what a selector is and the criteria common to all selectors.

A TypeSelector's job is to distinguish between types; types being classes, interfaces and enums. Listed below are the criteria which TypeSelector offers in addition to the criteria common to all selectors.

All TypeSelectors have to be given a description. A TypeSelector has an optional stereotype clause which will appear below the class title when viewed with a DiagramStyle which enables stereotyping.

Classes

To restrict the selector to only select classes use the classes keyword

Example

Matches all classes

TypeSelector allClasses description "classes, not interfaces"{
  classes named "*";
}

Note that after the keyword classes you must still supply a criterion. If you require all classes then letting their name match * is the easiest way to achieve this.

Interfaces

To restrict the selector to only include interfaces its list of criteria should be started with the keyword interfaces

Example

Matches all interfaces

TypeSelector allInterfaces {
  interfaces named "*";
}

Bytecode / Sourcecode

The Eclipse Java model is built from the sourcecode contained in all the Java projects open in the workbench and all referenced libraries. This criterion can be used to differentiate between types declared in the sourcecode and types declared in bytecode.

Example

Matches all types in a package with common in its name: for example com.xyz.common.provisioning and available as .class files or, more likely, a .jar file

TypeSelector valueObjects description "all value objects compiled in the common library" stereotype "Value Object" {
  types from bytecode & in package "*common*" ;
}

Subtype of

This criterion specifies that included types must have a supertype which matches another TypeSelector.

Example

The first TypeSelector only matches the one interface java.io.Serializable. The second TypeSelector uses the first to restrict selection to classes which implement java.io.Serializable.

TypeSelector justSerializable description "Just Serializable itself" {
  types named "Serializable" & in package "java.io" ;
}

TypeSelector serializableClasses description "all classes implementing serializable" stereotype "Serializable" {
  classes from sourcecode & subtype of justSerializable;
}

Package

The package criterion restricts selection to types whose package matches a supplied pattern. As with most other string matching criteria, the pattern can be specified directly, or via a pattern switch.

Example

see justSerializable above.

DependingUpon

This criterion is used to distinguish between types according to their dependencies.

Example

The first two TypeSelectors select types declared in awt and swing packages. The third TypeSelector matches any type which has a dependency upon either awt or swing.

TypeSelector awtTypes description "All types in the awt" {
  types in package "java.awt.*";
}

TypeSelector swingTypes description "All swing types" {
  types in package "javax.swing.*" ;
}

TypeSelector awtDependent description "All types which depend upon awt" {
  types depending upon awtTypes | depending upon swingTypes ;
}

Declares

A type declares another type, field or method if the type, field or method is declared within its scope. This criterion selects a type according to what it declares.

Example

The FieldSelector selects fields whose name ends with report. The TypeSelector selects types which have a field whose name ends with report.

FieldSelector reportFields {
  fields named "*report";
}

TypeSelector reportOwners description "Types which own a report" {
  types declaring reportFields;
}

Top Level

The declared by selection criterion common to all selectors works in the outwards direction and the declares criterion works in the inwards direction, but sometimes you want to restrict type selection to non-inner types.

Example

Matches top level (non-inner) classes whose name ends with Listener

TypeSelector topLevelListeners description "Top level listener classes" {
  classes named "*Listener" & top level types ;
}