Skip to content

Commit

Permalink
Added easy way to go from a Backend to a BackendSupport implement…
Browse files Browse the repository at this point in the history
…ation for that backend (ceylon/ceylon-spec#500)
  • Loading branch information
quintesse committed Apr 29, 2015
1 parent ea7bdf1 commit 71f608d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/com/redhat/ceylon/common/Backend.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
package com.redhat.ceylon.common;

public enum Backend {
Java("jvm"),
JavaScript("js");
Java("jvm", BackendSupport.JAVA),
JavaScript("js", BackendSupport.JAVASCRIPT);

public final String nativeAnnotation;
public final BackendSupport backendSupport;

Backend(String nativeAnnotation) {
Backend(String nativeAnnotation, BackendSupport backendSupport) {
this.nativeAnnotation = nativeAnnotation;
this.backendSupport = backendSupport;
}

public static boolean validAnnotation(String backend) {
Expand Down
14 changes: 14 additions & 0 deletions src/com/redhat/ceylon/common/BackendSupport.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,18 @@

public interface BackendSupport {
boolean supportsBackend(Backend backend);

public static final BackendSupport JAVA = new BackendSupport() {
@Override
public boolean supportsBackend(Backend backend) {
return backend == Backend.Java;
}
};

public static final BackendSupport JAVASCRIPT = new BackendSupport() {
@Override
public boolean supportsBackend(Backend backend) {
return backend == Backend.JavaScript;
}
};
}

0 comments on commit 71f608d

Please sign in to comment.