Example usage for java.util EnumSet noneOf

List of usage examples for java.util EnumSet noneOf

Introduction

In this page you can find the example usage for java.util EnumSet noneOf.

Prototype

public static <E extends Enum<E>> EnumSet<E> noneOf(Class<E> elementType) 

Source Link

Document

Creates an empty enum set with the specified element type.

Usage

From source file:org.lucasr.layoutsamples.adapter.TweetsAdapter.java

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    final TweetPresenter presenter;
    if (convertView == null) {
        presenter = (TweetPresenter) LayoutInflater.from(mContext).inflate(mPresenterId, parent, false);
    } else {/*from  w  ww  .j  a v  a 2  s  . co m*/
        presenter = (TweetPresenter) convertView;
    }

    Tweet tweet = (Tweet) getItem(position);
    presenter.update(tweet, EnumSet.noneOf(TweetPresenter.UpdateFlags.class));

    return (View) presenter;
}

From source file:org.apache.accumulo.core.util.shell.commands.DeleteIterCommand.java

@Override
public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws Exception {

    boolean tables = cl.hasOption(OptUtil.tableOpt().getOpt()) || !shellState.getTableName().isEmpty();
    boolean namespaces = cl.hasOption(OptUtil.namespaceOpt().getOpt());

    final String name = cl.getOptionValue(nameOpt.getOpt());

    if (namespaces) {
        if (!shellState.getConnector().namespaceOperations()
                .listIterators(OptUtil.getNamespaceOpt(cl, shellState)).containsKey(name)) {
            Shell.log.warn("no iterators found that match your criteria");
            return 0;
        }//from  w  w  w. j ava2s .  com
    } else if (tables) {
        if (!shellState.getConnector().tableOperations().listIterators(OptUtil.getTableOpt(cl, shellState))
                .containsKey(name)) {
            Shell.log.warn("no iterators found that match your criteria");
            return 0;
        }
    } else {
        throw new IllegalArgumentException("No table or namespace specified");
    }

    final EnumSet<IteratorScope> scopes = EnumSet.noneOf(IteratorScope.class);
    if (cl.hasOption(allScopeOpt.getOpt()) || cl.hasOption(mincScopeOpt.getOpt())) {
        scopes.add(IteratorScope.minc);
    }
    if (cl.hasOption(allScopeOpt.getOpt()) || cl.hasOption(majcScopeOpt.getOpt())) {
        scopes.add(IteratorScope.majc);
    }
    if (cl.hasOption(allScopeOpt.getOpt()) || cl.hasOption(scanScopeOpt.getOpt())) {
        scopes.add(IteratorScope.scan);
    }
    if (scopes.isEmpty()) {
        throw new IllegalArgumentException("You must select at least one scope to configure");
    }

    if (namespaces) {
        shellState.getConnector().namespaceOperations().removeIterator(OptUtil.getNamespaceOpt(cl, shellState),
                name, scopes);
    } else if (tables) {
        shellState.getConnector().tableOperations().removeIterator(OptUtil.getTableOpt(cl, shellState), name,
                scopes);
    } else {
        throw new IllegalArgumentException("No table or namespace specified");
    }
    return 0;
}

From source file:com.quinsoft.zeidon.utils.WriteOisToJsonStreamNoIncrementals.java

@Override
public void writeToStream(SerializeOi options, Writer writer) {
    this.viewList = options.getViewList();
    if (options.getFlags() == null)
        flags = EnumSet.noneOf(WriteOiFlags.class);
    else/*  w w  w  .j  a  v  a  2s .c o  m*/
        flags = options.getFlags();
    if (flags.contains(WriteOiFlags.INCREMENTAL))
        throw new ZeidonException("This JSON stream writer not intended for writing incremental.");

    this.options = options;

    JsonFactory jsonF = new JsonFactory();
    try {
        jg = jsonF.createGenerator(writer);
        jg.useDefaultPrettyPrinter(); // enable indentation just to make debug/testing easier
        jg.writeStartObject();

        jg.writeStringField("version", VERSION);

        for (View view : viewList)
            writeOi(view);

        jg.writeEndObject();
        jg.close();
    } catch (Exception e) {
        throw ZeidonException.wrapException(e);
    }
}

From source file:com.quinsoft.zeidon.standardoe.WriteOiToStream.java

/**
 * Class to write an OI to a stream./*from  www . j  ava  2  s .c  o m*/
 * @param view View to OI
 * @param writer Stream to write to
 * @param name Description of object (usually file name)
 * @param control Write options.
 */
WriteOiToStream(ViewImpl view, Writer writer, String name, long control) {
    super();
    this.view = view;
    this.writer = writer;
    this.name = name;

    flags = EnumSet.noneOf(WriteOiFlags.class);
    if ((control & View.CONTROL_INCREMENTAL) != 0)
        flags.add(WriteOiFlags.fINCREMENTAL);

    if ((control & View.CONTROL_ENTITY_KEYS) != 0)
        flags.add(WriteOiFlags.fENTITY_KEYS);

    if ((control & View.CONTROL_ENTITY_TAGS) != 0)
        flags.add(WriteOiFlags.fENTITY_TAGS);

    if ((control & View.CONTROL_KEYS_ONLY) != 0)
        flags.add(WriteOiFlags.fKEYS_ONLY);
}

From source file:com.janrain.backplane.server.BusConfig1.java

public Collection<BUS_PERMISSION> getPermissions(String user) {
    if (isBusConfigField(user)) {
        throw new IllegalArgumentException("Invalid user name: " + user);
    }//from ww  w  .  java2s  .co  m

    String perms = get(user);
    EnumSet<BUS_PERMISSION> result = EnumSet.noneOf(BUS_PERMISSION.class);
    if (StringUtils.isNotBlank(perms)) {
        for (String perm : perms.split(",")) {
            result.add(BUS_PERMISSION.valueOf(perm));
        }
    }
    return result;
}

From source file:com.google.i18n.addressinput.common.FormatInterpreter.java

/**
 * Returns a list of address fields based on the format of {@code regionCode}. Script type is
 * needed because some countries uses different address formats for local/Latin scripts.
 *
 * @param scriptType if {@link ScriptType#LOCAL}, use local format; else use Latin format.
 *//* w w w. ja  v  a  2s  .  c  o m*/
// TODO: Consider not re-doing this work every time the widget is re-rendered.
@SuppressWarnings("deprecation") // For legacy address fields.
public List<AddressField> getAddressFieldOrder(ScriptType scriptType, String regionCode) {
    Util.checkNotNull(scriptType);
    Util.checkNotNull(regionCode);
    EnumSet<AddressField> visibleFields = EnumSet.noneOf(AddressField.class);
    List<AddressField> fieldOrder = new ArrayList<AddressField>();
    // TODO: Change this to just enumerate the address fields directly.
    for (String substring : getFormatSubStrings(scriptType, regionCode)) {
        // Skips un-escaped characters and new lines.
        if (!substring.matches("%.") || substring.equals(NEW_LINE)) {
            continue;
        }
        AddressField field = AddressField.of(substring.charAt(1));
        // Accept only the first instance for any duplicate fields (which can occur because the
        // string we start with defines format order, which can contain duplicate fields).
        if (!visibleFields.contains(field)) {
            visibleFields.add(field);
            fieldOrder.add(field);
        }
    }
    applyFieldOrderOverrides(regionCode, fieldOrder);

    // Uses two address lines instead of street address.
    for (int n = 0; n < fieldOrder.size(); n++) {
        if (fieldOrder.get(n) == AddressField.STREET_ADDRESS) {
            fieldOrder.set(n, AddressField.ADDRESS_LINE_1);
            fieldOrder.add(n + 1, AddressField.ADDRESS_LINE_2);
            break;
        }
    }
    return Collections.unmodifiableList(fieldOrder);
}

From source file:org.apache.hadoop.hdfs.TestHFlush.java

/**
 * The test uses/*  ww w .j av  a 2  s  .  co m*/
 * {@link #doTheJob(Configuration, String, long, short, boolean, EnumSet)}
 * to write a file with a standard block size
 */
@Test
public void hFlush_01() throws IOException {
    doTheJob(new HdfsConfiguration(), fName, AppendTestUtil.BLOCK_SIZE, (short) 2, false,
            EnumSet.noneOf(SyncFlag.class));
}

From source file:com.inmobi.conduit.distcp.tools.util.TestDistCpUtils.java

@Test
public void testPackAttributes() {
    EnumSet<FileAttribute> attributes = EnumSet.noneOf(FileAttribute.class);
    Assert.assertEquals(DistCpUtils.packAttributes(attributes), "");

    attributes.add(FileAttribute.REPLICATION);
    Assert.assertEquals(DistCpUtils.packAttributes(attributes), "R");
    Assert.assertEquals(attributes, DistCpUtils.unpackAttributes("R"));

    attributes.add(FileAttribute.BLOCKSIZE);
    Assert.assertEquals(DistCpUtils.packAttributes(attributes), "RB");
    Assert.assertEquals(attributes, DistCpUtils.unpackAttributes("RB"));

    attributes.add(FileAttribute.USER);
    Assert.assertEquals(DistCpUtils.packAttributes(attributes), "RBU");
    Assert.assertEquals(attributes, DistCpUtils.unpackAttributes("RBU"));

    attributes.add(FileAttribute.GROUP);
    Assert.assertEquals(DistCpUtils.packAttributes(attributes), "RBUG");
    Assert.assertEquals(attributes, DistCpUtils.unpackAttributes("RBUG"));

    attributes.add(FileAttribute.PERMISSION);
    Assert.assertEquals(DistCpUtils.packAttributes(attributes), "RBUGP");
    Assert.assertEquals(attributes, DistCpUtils.unpackAttributes("RBUGP"));
}

From source file:org.easyrec.service.core.impl.JSONProfileServiceImpl.java

@Override
public void afterPropertiesSet() throws Exception {

    Configuration.setDefaults(new Configuration.Defaults() {

        private final JsonProvider jsonProvider = new JacksonJsonProvider();

        @Override//  ww w. j  a  va  2 s .co m
        public JsonProvider jsonProvider() {
            return jsonProvider;
        }

        @Override
        public Set<Option> options() {
            return EnumSet.noneOf(Option.class);
        }

        @Override
        public MappingProvider mappingProvider() {
            return new JacksonMappingProvider();
        }
    });

}

From source file:com.pros.jsontransform.examples.paths.JsonPathTest.java

@Test
public void test() throws IOException, ObjectTransformerException {
    jsonSource = JunitTools.readFile(pathToJson + "/" + fileNamePrefix + "Source.json");

    Configuration.setDefaults(new Configuration.Defaults() {
        private final JsonProvider jsonProvider = new JacksonJsonNodeJsonProvider();
        private final MappingProvider mappingProvider = new JacksonMappingProvider();

        @Override// w  ww . j av  a  2  s . co  m
        public JsonProvider jsonProvider() {
            return jsonProvider;
        }

        @Override
        public MappingProvider mappingProvider() {
            return mappingProvider;
        }

        @Override
        public Set<Option> options() {
            return EnumSet.noneOf(Option.class);
        }
    });

    Object document = Configuration.defaultConfiguration().jsonProvider().parse(jsonSource);

    // get first author
    JsonNode author0 = JsonPath.read(document, "$.store.book[0].author");

    // get Moby Dick book and author
    JsonNode mobyDickBook = JsonPath.read(document, "$..book[?(@.title == 'Moby Dick')]]");
    JsonNode mobyDickAuthor = JsonPath.read(mobyDickBook, "$[0].author");

    System.out.println(jsonSource);
    System.out.println(mapper.writerWithDefaultPrettyPrinter().writeValueAsString(author0));
    System.out.println(mapper.writerWithDefaultPrettyPrinter().writeValueAsString(mobyDickBook));
    System.out.println(mapper.writerWithDefaultPrettyPrinter().writeValueAsString(mobyDickAuthor));
}