List of usage examples for org.eclipse.jgit.lib Config setEnum
public <T extends Enum<?>> void setEnum(final String section, final String subsection, final String name, final T value)
From source file:com.google.gerrit.elasticsearch.ElasticTestUtils.java
License:Apache License
static void configure(Config config, String port) { config.setEnum("index", null, "type", IndexType.ELASTICSEARCH); config.setString("index", null, "protocol", "http"); config.setString("index", null, "hostname", "localhost"); config.setString("index", null, "port", port); config.setBoolean("index", "elasticsearch", "test", true); }
From source file:com.google.gerrit.server.config.ConfigUtil.java
License:Apache License
/** * Store section by inspecting Java class attributes. * <p>/* w w w . j a v a2 s . c o m*/ * Optimize the storage by unsetting a variable if it is * being set to default value by the server. * <p> * Fields marked with final or transient modifiers are skipped. * * @param cfg config in which the values should be stored * @param section section * @param sub subsection * @param s instance of class with config values * @param defaults instance of class with default values * @throws ConfigInvalidException */ public static <T> void storeSection(Config cfg, String section, String sub, T s, T defaults) throws ConfigInvalidException { try { for (Field f : s.getClass().getDeclaredFields()) { if (skipField(f)) { continue; } Class<?> t = f.getType(); String n = f.getName(); f.setAccessible(true); Object c = f.get(s); Object d = f.get(defaults); Preconditions.checkNotNull(d, "Default cannot be null"); if (c == null || c.equals(d)) { cfg.unset(section, sub, n); } else { if (isString(t)) { cfg.setString(section, sub, n, (String) c); } else if (isInteger(t)) { cfg.setInt(section, sub, n, (Integer) c); } else if (isLong(t)) { cfg.setLong(section, sub, n, (Long) c); } else if (isBoolean(t)) { cfg.setBoolean(section, sub, n, (Boolean) c); } else if (t.isEnum()) { cfg.setEnum(section, sub, n, (Enum<?>) c); } else { throw new ConfigInvalidException("type is unknown: " + t.getName()); } } } } catch (SecurityException | IllegalArgumentException | IllegalAccessException e) { throw new ConfigInvalidException("cannot save values", e); } }
From source file:com.google.gerrit.server.git.VersionedMetaData.java
License:Apache License
protected static <E extends Enum<?>> void set(Config rc, String section, String subsection, String name, E value, E defaultValue) {/* w ww .java2 s .c o m*/ if (value != defaultValue) { rc.setEnum(section, subsection, name, value); } else { rc.unset(section, subsection, name); } }
From source file:com.google.gerrit.testutil.InMemoryModule.java
License:Apache License
public static void setDefaults(Config cfg) { cfg.setEnum("auth", null, "type", AuthType.DEVELOPMENT_BECOME_ANY_ACCOUNT); cfg.setString("gerrit", null, "allProjects", "Test-Projects"); cfg.setString("gerrit", null, "basePath", "git"); cfg.setString("gerrit", null, "canonicalWebUrl", "http://test/"); cfg.setString("user", null, "name", "Gerrit Code Review"); cfg.setString("user", null, "email", "gerrit@localhost"); cfg.unset("cache", null, "directory"); cfg.setString("index", null, "type", "lucene"); cfg.setBoolean("index", "lucene", "testInmemory", true); cfg.setInt("index", "lucene", "testVersion", ChangeSchemas.getLatest().getVersion()); cfg.setInt("sendemail", null, "threadPoolSize", 0); cfg.setBoolean("receive", null, "enableSignedPush", false); cfg.setString("receive", null, "certNonceSeed", "sekret"); }
From source file:org.eclipse.mylyn.reviews.r4e.ui.tests.utils.TestUtils.java
License:Open Source License
private static Repository createRepository(IProject aProject) throws CoreException, IOException { TestUtils.waitForJobs();//from www . jav a2 s . c o m File gitDir = new File(aProject.getLocation().toOSString(), Constants.DOT_GIT); Repository repository = new FileRepository(gitDir); try { repository.create(); Config storedConfig = repository.getConfig(); storedConfig.setEnum("core", null, "autocrlf", AutoCRLF.FALSE); } catch (IllegalStateException e) { //Jusy go on } return repository; }