@Override public UserModifiableConfiguration set(String path, Object value) { ConfigElement.PathIdentifier pp = ConfigElement.parse(config.getRootNamespace(),path); Preconditions.checkArgument(pp.element.isOption(),"Need to provide configuration option - not namespace: %s",path); ConfigOption option = (ConfigOption)pp.element; verifier.verifyModification(option); if (option.getDatatype().isArray()) { Class arrayType = option.getDatatype().getComponentType(); Object arr; if (value.getClass().isArray()) { int size = Array.getLength(value); arr = Array.newInstance(arrayType,size); for (int i=0;i<size;i++) { Array.set(arr,i,convertBasic(Array.get(value,i),arrayType)); } } else { arr = Array.newInstance(arrayType,1); Array.set(arr,0,convertBasic(value,arrayType)); } value = arr; } else { value = convertBasic(value,option.getDatatype()); } config.set(option,value,pp.umbrellaElements); return this; }
@Override public boolean has(ConfigOption option, String... umbrellaElements) { final String key = super.getPath(option, umbrellaElements); return option.isLocal() && local.get(key, option.getDatatype()) != null || option.isGlobal() && global.get(key, option.getDatatype()) != null; }
@Override public<O> O get(ConfigOption<O> option, String... umbrellaElements) { final String key = super.getPath(option,umbrellaElements); Object result = null; if (option.isLocal()) { result = local.get(key,option.getDatatype()); } if (result==null && option.isGlobal()) { result = global.get(key,option.getDatatype()); } return option.get(result); }
@Override public boolean has(ConfigOption option, String... umbrellaElements) { verifyOption(option); return config.get(super.getPath(option,umbrellaElements),option.getDatatype())!=null; }
private void checkBackwardCompatibilityWithTitan(ModifiableConfiguration globalWrite, BasicConfiguration localBasicConfiguration, KCVSConfiguration keyColumnValueStoreConfiguration, ModifiableConfiguration overwrite) { String version = globalWrite.get(TITAN_COMPATIBLE_VERSIONS); Preconditions.checkArgument(version!=null,"JanusGraph version nor Titan compatibility have not been initialized"); if (!JanusGraphConstants.TITAN_COMPATIBLE_VERSIONS.contains(version)) { throw new JanusGraphException(String.format(INCOMPATIBLE_VERSION_EXCEPTION, version, JanusGraphConstants.VERSION)); } // When connecting to a store created by Titan the ID store name will not be in the // global configuration as it was not something which was configurable with Titan. // So to ensure compatibility override the default to titan_ids. boolean localIdStoreIsDefault = JanusGraphConstants.JANUSGRAPH_ID_STORE_NAME.equals(localBasicConfiguration.get(IDS_STORE_NAME)); boolean usingTitanIdStore = localIdStoreIsDefault || JanusGraphConstants.TITAN_ID_STORE_NAME.equals(localBasicConfiguration.get(IDS_STORE_NAME)); boolean existingKeyStore = keyColumnValueStoreConfiguration.get(IDS_STORE_NAME.getName(), IDS_STORE_NAME.getDatatype()) != null; Preconditions.checkArgument(usingTitanIdStore,"ID store for Titan compatibility has not been initialized to: " + JanusGraphConstants.TITAN_ID_STORE_NAME); if (!existingKeyStore) { log.info("Setting {} to {} for Titan compatibility", IDS_STORE_NAME.getName(), JanusGraphConstants.TITAN_ID_STORE_NAME); overwrite.set(IDS_STORE_NAME, JanusGraphConstants.TITAN_ID_STORE_NAME); } }
String description = "# " + WordUtils.wrap(opt.getDescription(), WRAP_COLUMNS, "\n# ", false); String dt = "# Data Type: "; if (opt.getDatatype().isArray()) { dt += opt.getDatatype().getComponentType().toString() + "[]"; } else if (opt.getDatatype().isEnum()) { Enum[] enums = (Enum[])opt.getDatatype().getEnumConstants(); String[] names = new String[enums.length]; for (int i = 0; i < names.length; i++) names[i] = enums[i].name(); dt += opt.getDatatype().getSimpleName() + " enum:"; String s = "\n# " + "{ " + Joiner.on(", ").join(names) + " }"; dt += WordUtils.wrap(s, WRAP_COLUMNS, "\n# ", false); } else { dt += opt.getDatatype().getSimpleName(); } else if (opt.getDatatype().isArray()) { defaultValue += Joiner.on(", ").join((Object[]) opt.getDefaultValue()); } else if (opt.getDatatype().isEnum()) { defaultValue += ((Enum)opt.getDefaultValue()).name(); } else {
public static String toString(ConfigElement element) { String result = element.getName(); if (element.isNamespace()) { result = "+ " + result; if (((ConfigNamespace)element).isUmbrella()) result += " [*]"; } else { result = "- " + result; ConfigOption option = (ConfigOption)element; result+= " ["; switch (option.getType()) { case FIXED: result+="f"; break; case GLOBAL_OFFLINE: result+="g!"; break; case GLOBAL: result+="g"; break; case MASKABLE: result+="m"; break; case LOCAL: result+="l"; break; } result+=","+option.getDatatype().getSimpleName(); result+=","+option.getDefaultValue(); result+="]"; } result = result + "\n"; String desc = element.getDescription(); result+="\t"+'"'+desc.substring(0, Math.min(desc.length(), 50))+'"'; return result; }
Object o = new CommonsConfiguration(apc).get(key, opt.getDatatype()); opt.verify(o); keysVerified++;
private String getTableLineForOption(ConfigOption o, String prefix) { final List<String> colData = new ArrayList<>(10); String name = prefix + o.getName(); if (o.isDeprecated()) { ConfigOption<?> successor = o.getDeprecationReplacement(); if (null == successor) { name = "[deprecation-warning]*Deprecated* [line-through]#" + name + "#"; } else { name = "[deprecation-warning]*Deprecated. See " + getFullPath(successor) + "* [line-through]#" + name + "#"; } } colData.add(name); colData.add(removeDelim(o.getDescription())); colData.add(o.getDatatype().getSimpleName()); colData.add(removeDelim(getStringForDefaultValue(o))); if (showMutability) colData.add(o.getType().toString()); String line = Joiner.on(DELIM_PADDING + DELIM + DELIM_PADDING).join(colData); if (DELIM_AT_LINE_START) { line = DELIM + DELIM_PADDING + line; } if (DELIM_AT_LINE_END) { line = line + DELIM_PADDING + DELIM; } return line; }
@Override public<O> O get(ConfigOption<O> option, String... umbrellaElements) { verifyOption(option); O result = config.get(super.getPath(option,umbrellaElements),option.getDatatype()); return option.get(result); }