Example usage for java.util Objects isNull

List of usage examples for java.util Objects isNull

Introduction

In this page you can find the example usage for java.util Objects isNull.

Prototype

public static boolean isNull(Object obj) 

Source Link

Document

Returns true if the provided reference is null otherwise returns false .

Usage

From source file:de.bruse.c2x.cli.Main.java

public static void main(String[] args) {
    CommandLineParser parser = new GnuParser();
    Options options = new Options();

    Option input = new Option("i", INPUT, HAS_ARGS, "CityGML file to be converted.");
    input.setArgs(ONE);//w ww . j  a v  a  2s . c o m
    input.setArgName(INPUT);
    input.setRequired(Boolean.TRUE);
    options.addOption(input);

    Option levelOfDetail = new Option("l", LEVEL_OF_DETAIL, HAS_ARGS,
            "Level of detail to be converted. Possible values are LOD1 and LOD2.");
    levelOfDetail.setArgs(ONE);
    levelOfDetail.setArgName(LEVEL_OF_DETAIL);
    levelOfDetail.setRequired(Boolean.TRUE);
    options.addOption(levelOfDetail);

    Option geometryType = new Option("t", GEOMETRY_TYPE, HAS_ARGS,
            "Geometry type to be converted. Possible values are SOLID and MULTI_SURFACE.");
    geometryType.setArgs(ONE);
    geometryType.setArgName(GEOMETRY_TYPE);
    geometryType.setRequired(Boolean.TRUE);
    options.addOption(geometryType);

    Option output = new Option("o", OUTPUT, HAS_ARGS, "File path of the output file.");
    output.setArgs(ONE);
    output.setArgName(OUTPUT);
    output.setRequired(Boolean.FALSE);
    options.addOption(output);

    Option targetFormat = new Option("f", FORMAT, HAS_ARGS,
            "Format of the output file. Possible values are X3D and COLLADA.");
    targetFormat.setArgs(ONE);
    targetFormat.setArgName(FORMAT);
    targetFormat.setRequired(Boolean.TRUE);
    options.addOption(targetFormat);

    Option split = new Option("s", SPLIT, NO_ARGS, "Generate one scene node for each building (X3D only).");
    split.setArgName(SPLIT);
    split.setRequired(Boolean.FALSE);
    options.addOption(split);

    Option validate = new Option("v", VALIDATE, NO_ARGS, "Validate the CityGML file.");
    validate.setArgName(VALIDATE);
    validate.setRequired(Boolean.FALSE);
    options.addOption(validate);

    try {
        CommandLine line = parser.parse(options, args);
        if (line.hasOption(INPUT) && line.hasOption(LEVEL_OF_DETAIL) && line.hasOption(GEOMETRY_TYPE)
                && line.hasOption(FORMAT)) {
            String inputValue = line.getOptionValue(INPUT);
            String levelOfDetailValue = line.getOptionValue(LEVEL_OF_DETAIL);
            String geometryTypeValue = line.getOptionValue(GEOMETRY_TYPE);
            String targetFormatValue = line.getOptionValue(FORMAT);
            String outputValue = line.getOptionValue(OUTPUT);
            LevelOfDetail lod = LevelOfDetail.valueOf(levelOfDetailValue);
            GeometryType type = GeometryType.valueOf(geometryTypeValue);
            if (Objects.isNull(lod) || Objects.isNull(type)
                    || (!targetFormatValue.equals(X3D) && !targetFormatValue.equals(COLLADA))) {
                printHelp(options);
            } else {
                if (line.hasOption(VALIDATE)) {
                    triggerValidation(inputValue);
                }
                if (targetFormatValue.equals(X3D)) {
                    boolean splitValue = false;
                    if (line.hasOption(SPLIT)) {
                        splitValue = true;
                    }
                    if (Objects.isNull(outputValue) || outputValue.isEmpty()) {
                        outputValue = inputValue + X3D_FILE_EXT;
                    }
                    triggerX3DConversion(inputValue, lod, type, outputValue, splitValue);
                } else if (targetFormatValue.equals(COLLADA)) {
                    if (Objects.isNull(outputValue) || outputValue.isEmpty()) {
                        outputValue = inputValue + COLLADA_FILE_EXT;
                    }
                    triggerColladaConversion(inputValue, lod, type, outputValue);
                }
                System.out.println("Conversion succeeded.");
            }
        } else {
            printHelp(options);
        }
    } catch (ParseException | IllegalArgumentException e) {
        printHelp(options);
    } catch (ValidationException e) {
        System.out.println("Input file is invalid. Operation canceled.\n" + e.getMessage());
    } catch (ConversionException e) {
        String message = "Failed to convert CityGML.";
        if (Objects.nonNull(e.getMessage())) {
            message += " " + e.getMessage();
        }
        System.out.println(message);
    } catch (IOException e) {
        System.out.println("Failed to read from file '" + input + "'.");
    }
}

From source file:org.kitodo.config.Config.java

/**
 * Returns the configuration./*w w w  .j a  v  a  2 s .c o m*/
 *
 * @param configFile
 *            file with configuration
 * @return the configuration
 */
static PropertiesConfiguration getConfig(String configFile) {
    if (Objects.isNull(config)) {
        synchronized (Config.class) {
            PropertiesConfiguration initialized = config;
            if (Objects.isNull(initialized)) {
                AbstractConfiguration.setDefaultListDelimiter('&');
                try {
                    initialized = new PropertiesConfiguration(configFile);
                } catch (ConfigurationException e) {
                    logger.warn(
                            "Loading of " + configFile + " failed. Trying to start with empty configuration.",
                            e);
                    initialized = new PropertiesConfiguration();
                }
                initialized.setListDelimiter('&');
                initialized.setReloadingStrategy(new FileChangedReloadingStrategy());
                initialized.setThrowExceptionOnMissing(true);
                config = initialized;
            }
        }
    }
    return config;
}

From source file:cc.sion.core.persistence.SearchFilter.java

/**
 * searchParamskey?OPERATOR_FIELDNAME//  w w  w.j  a v  a  2  s . c o m
 */
public static Map<String, SearchFilter> parse(Map<String, Object> searchParams) {
    Map<String, SearchFilter> filters = new HashMap<String, SearchFilter>();

    for (Entry<String, Object> entry : searchParams.entrySet()) {
        // 
        String key = entry.getKey();
        Object value = entry.getValue();
        if (Objects.isNull(value)) {
            continue;
        }

        if (log.isDebugEnabled()) {
            //EQ_userId    10086
            log.debug("searchParams>>>key:{},value:{}", key, value);
        }

        // operatorfiledAttribute
        String[] names = StringUtils.split(key, "_");
        if (names.length != 2) {
            throw new IllegalArgumentException(key + " is not a valid search filter name");
        }
        String filedName = names[1];
        Operator operator = Operator.valueOf(names[0]);

        // searchFilter
        SearchFilter filter = new SearchFilter(filedName, operator, value);
        filters.put(key, filter);
    }

    return filters;
}

From source file:com.isalnikov.utils.MessageHelper.java

public String getMessage(Locale Locale, Object... params) {

    Assert.state(!(Objects.isNull(params) || params.length == 0 || params[0] == null
            || ((String) params[0]).isEmpty()), "MessageHelper getMessage -> params is null");

    Object[] args = new Object[] {};

    if (params.length > 1) {
        args = new Object[params.length - 1];
        System.arraycopy(params, 1, args, 0, params.length - 1);
    }//from  w ww  .j  a  v  a 2s.  c om

    String result = messageSource.getMessage((String) params[0], args, Locale);
    return result;
}

From source file:com.mac.holdempoker.app.hands.Straight.java

@Override
public Card[] getHand() {
    if (Objects.isNull(super.getFinalHand())) {
        this.setFinalHand(findStraight());
    }/*from   w  w w  .  j  a v a  2s  . co m*/
    return super.getFinalHand();
}

From source file:com.mac.holdempoker.app.hands.Boat.java

@Override
public Card[] getHand() {
    if (Objects.isNull(super.getFinalHand())) {
        this.setFinalHand(findBoat());
    }/*from  w  ww  .j  a v  a2 s  .c  o  m*/
    return super.getFinalHand();
}

From source file:com.mac.holdempoker.app.hands.TwoPair.java

@Override
public Card[] getHand() {
    if (Objects.isNull(super.getFinalHand())) {
        this.setFinalHand(findTwoPair());
    }/*  ww w  .  j  ava 2 s.c om*/
    return super.getFinalHand();
}

From source file:com.mac.holdempoker.app.hands.Pair.java

@Override
public Card[] getHand() {
    if (Objects.isNull(super.getFinalHand())) {
        this.setFinalHand(findPair());
    }// ww  w . j ava  2  s.co  m
    return super.getFinalHand();
}

From source file:com.mac.holdempoker.app.hands.Set.java

@Override
public Card[] getHand() {
    if (Objects.isNull(super.getFinalHand())) {
        this.setFinalHand(findSet());
    }/* w  w w.j  a v a  2 s .com*/
    return super.getFinalHand();
}

From source file:com.mac.holdempoker.app.hands.Quad.java

@Override
public Card[] getHand() {
    if (Objects.isNull(super.getFinalHand())) {
        this.setFinalHand(findQuad());
    }//  w w w .  j a va2 s  .c  o m
    return super.getFinalHand();
}