Skip to content

Instantly share code, notes, and snippets.

@craigleonard
Created October 1, 2021 09:49
Show Gist options
  • Save craigleonard/63161cd851d5807968eb53a1b178e5cc to your computer and use it in GitHub Desktop.
Save craigleonard/63161cd851d5807968eb53a1b178e5cc to your computer and use it in GitHub Desktop.
import java.util.HashMap;
import java.util.List;
import java.util.Map;
class CodeFlags {
public static final int FLAG_INCLUDE_VERSIONS = 0x1;
public static final int FLAG_INCLUDE_FILES = 0x2;
public static final int FLAG_INCLUDE_CATEGORY_AND_TAGS = 0x4;
public static final int FLAG_INCLUDE_SHARED_ACCOUNTS = 0x8;
public static final int FLAG_INCLUDE_VERSION_PROPERTIES = 0x10;
public static final int FLAG_EXCLUDE_NON_VALIDATED = 0x20;
public static final int FLAG_INCLUDE_INSTALLATION_TARGETS = 0x40;
public static final int FLAG_INCLUDE_ASSET_URI = 0x80;
public static final int FLAG_INCLUDE_STATISTICS = 0x100;
public static final int FLAG_INCLUDE_LATEST_VERSION_ONLY = 0x200;
public static final int FLAG_UNPUBLISHED = 0x1000;
public static void main(String[] args) {
Map<String, Integer> flags = new HashMap<>();
flags.put("FLAG_INCLUDE_VERSIONS",FLAG_INCLUDE_VERSIONS);
flags.put("FLAG_INCLUDE_FILES",FLAG_INCLUDE_FILES);
flags.put("FLAG_INCLUDE_CATEGORY_AND_TAGS",FLAG_INCLUDE_CATEGORY_AND_TAGS);
flags.put("FLAG_INCLUDE_SHARED_ACCOUNTS",FLAG_INCLUDE_SHARED_ACCOUNTS);
flags.put("FLAG_INCLUDE_VERSION_PROPERTIES",FLAG_INCLUDE_VERSION_PROPERTIES);
flags.put("FLAG_EXCLUDE_NON_VALIDATED",FLAG_EXCLUDE_NON_VALIDATED);
flags.put("FLAG_INCLUDE_INSTALLATION_TARGET",FLAG_INCLUDE_INSTALLATION_TARGETS);
flags.put("FLAG_INCLUDE_ASSET_URI",FLAG_INCLUDE_ASSET_URI);
flags.put("FLAG_INCLUDE_STATISTICS",FLAG_INCLUDE_STATISTICS);
flags.put("FLAG_INCLUDE_LATEST_VERSION_ONLY",FLAG_INCLUDE_LATEST_VERSION_ONLY);
flags.put("FLAG_UNPUBLISHED",FLAG_UNPUBLISHED);
flags.forEach((flagName, flagValue) -> {
System.out.println(flagName + " = " + test(950, flagValue));
});
}
private static boolean test(int flags, int flag) {
return (flags & flag) != 0;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment