/**
* Resource scopes are used to group some types of resources. For example Java methods, Flex methods, C functions
* and Cobol paragraphs are grouped in the scope "block unit".
- *
+ * <p/>
* Scopes are generally used in UI to display/hide some services or in web services.
- *
+ * <p/>
* Scopes are not extensible by plugins.
*
* @since 2.6
private Scopes() {
// only static methods
}
+
/**
* For example view, subview, project, module or library. Persisted in database.
*/
/**
* Types like Java classes/interfaces. Not persisted in database.
*/
- public static final String TYPE = "TYP";
+ public static final String PROGRAM_UNIT = "PGU";
/**
* Block units like methods, functions or Cobol paragraphs.
*/
public static final String BLOCK_UNIT = "BLU";
- public static final String[] SORTED_SCOPES = {PROJECT, DIRECTORY, FILE, TYPE, BLOCK_UNIT};
+ public static final String[] SORTED_SCOPES = {PROJECT, DIRECTORY, FILE, PROGRAM_UNIT, BLOCK_UNIT};
public static boolean isProject(final Resource resource) {
return StringUtils.equals(DIRECTORY, resource.getScope());
}
+ /**
+ * This scope is sometimes called a "compilation unit".
+ */
public static boolean isFile(final Resource resource) {
return StringUtils.equals(FILE, resource.getScope());
}
- public static boolean isType(final Resource resource) {
- return StringUtils.equals(TYPE, resource.getScope());
+ /**
+ * A program unit can be a Java class.
+ */
+ public static boolean isProgramUnit(final Resource resource) {
+ return StringUtils.equals(PROGRAM_UNIT, resource.getScope());
}
public static boolean isBlockUnit(final Resource resource) {
public static boolean isHigherThan(final String scope, final String than) {
int index = ArrayUtils.indexOf(SORTED_SCOPES, scope);
int thanIndex = ArrayUtils.indexOf(SORTED_SCOPES, than);
- return index<thanIndex;
+ return index < thanIndex;
}
public static boolean isHigherThanOrEquals(final Resource resource, final String than) {
public static boolean isHigherThanOrEquals(final String scope, final String than) {
int index = ArrayUtils.indexOf(SORTED_SCOPES, scope);
int thanIndex = ArrayUtils.indexOf(SORTED_SCOPES, than);
- return index<=thanIndex;
+ return index <= thanIndex;
}
}
\ No newline at end of file
assertThat(Scopes.isDirectory(resource), is(false));
assertThat(Scopes.isFile(resource), is(false));
assertThat(Scopes.isBlockUnit(resource), is(false));
- assertThat(Scopes.isType(resource), is(false));
+ assertThat(Scopes.isProgramUnit(resource), is(false));
}
@Test
assertThat(Scopes.isDirectory(resource), is(false));
assertThat(Scopes.isFile(resource), is(false));
assertThat(Scopes.isBlockUnit(resource), is(false));
- assertThat(Scopes.isType(resource), is(false));
+ assertThat(Scopes.isProgramUnit(resource), is(false));
}
@Test
assertThat(Scopes.isDirectory(resource), is(true));
assertThat(Scopes.isFile(resource), is(false));
assertThat(Scopes.isBlockUnit(resource), is(false));
- assertThat(Scopes.isType(resource), is(false));
+ assertThat(Scopes.isProgramUnit(resource), is(false));
}
@Test
assertThat(Scopes.isDirectory(resource), is(false));
assertThat(Scopes.isFile(resource), is(true));
assertThat(Scopes.isBlockUnit(resource), is(false));
- assertThat(Scopes.isType(resource), is(false));
+ assertThat(Scopes.isProgramUnit(resource), is(false));
}
@Test