Skip to content

Commit

Permalink
Merge 2.2 into 2.3
Browse files Browse the repository at this point in the history
  • Loading branch information
thobe committed Dec 1, 2015
2 parents de360af + dbcacd7 commit b1f759a
Show file tree
Hide file tree
Showing 15 changed files with 1,880 additions and 16 deletions.
59 changes: 46 additions & 13 deletions community/kernel/src/main/java/org/neo4j/helpers/Args.java
Original file line number Diff line number Diff line change
Expand Up @@ -251,29 +251,57 @@ public long getDuration( String key, long defaultValueInMillis)
return value != null ? TimeUtil.parseTimeMillis.apply(value) : defaultValueInMillis;
}

public Boolean getBoolean( String key, Boolean defaultValue )
/**
* Like calling {@link #getBoolean(String, Boolean)} with {@code false} for default value.
* This is the most common case, i.e. returns {@code true} if boolean argument was specified as:
* <ul>
* <li>--myboolean</li>
* <li>--myboolean=true</li>
* </ul>
* Otherwise {@code false.
* }
* @param key argument key.
* @return {@code true} if argument was specified w/o value, or w/ value {@code true}, otherwise {@code false}.
*/
public boolean getBoolean( String key )
{
String value = getSingleOptionOrNull( key );
return getBoolean( key, false );
}

// Apparently this condition must be split like this, instead of as an elvis operator,
// because defaultValue will, in that case, be evaluated as a primitive boolean and
// a NullPointerException will insue. Odd.
if ( value != null )
{
return Boolean.parseBoolean( value );
}
return defaultValue;
/**
* Like calling {@link #getBoolean(String, Boolean, Boolean)} with {@code true} for
* {@code defaultValueIfNoValue}, i.e. specifying {@code --myarg} will interpret it as {@code true}.
*/
public Boolean getBoolean( String key, Boolean defaultValueIfNotSpecified )
{
return getBoolean( key, defaultValueIfNotSpecified, Boolean.TRUE );
}

public Boolean getBoolean( String key, Boolean defaultValueIfNotFound,
Boolean defaultValueIfNoValue )
/**
* Parses a {@code boolean} argument. There are a couple of cases:
* <ul>
* <li>The argument isn't specified. In this case the value of {@code defaultValueIfNotSpecified}
* will be returned.</li>
* <li>The argument is specified without value, for example <pre>--myboolean</pre>. In this case
* the value of {@code defaultValueIfNotSpecified} will be returned.</li>
* <li>The argument is specified with value, for example <pre>--myboolean=true</pre>.
* In this case the actual value will be returned.</li>
* </ul>
*
* @param key argument key.
* @param defaultValueIfNotSpecified used if argument not specified.
* @param defaultValueIfSpecifiedButNoValue used if argument specified w/o value.
* @return argument boolean value depending on what was specified, see above.
*/
public Boolean getBoolean( String key, Boolean defaultValueIfNotSpecified,
Boolean defaultValueIfSpecifiedButNoValue )
{
String value = getSingleOptionOrNull( key );
if ( value != null )
{
return Boolean.parseBoolean( value );
}
return this.map.containsKey( key ) ? defaultValueIfNoValue : defaultValueIfNotFound;
return this.map.containsKey( key ) ? defaultValueIfSpecifiedButNoValue : defaultValueIfNotSpecified;
}

public <T extends Enum<T>> T getEnum( Class<T> enumClass, String key, T defaultValue )
Expand All @@ -299,6 +327,11 @@ public List<String> orphans()
return new ArrayList<>( this.orphans );
}

public String[] orphansAsArray()
{
return orphans.toArray( new String[orphans.size()] );
}

public String[] asArgs()
{
List<String> list = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ public enum TransactionApplicationMode
* a recovered transaction may have already been applied previously to the store.
*/
RECOVERY(
false, // id tracking not needed because id generators will be rebuilt after recovery anyway
true, // id tracking not needed because id generators will be rebuilt after recovery anyway
false, // during recovery there's not really a cache to invalidate so don't bother
true // extra care needs to be taken to ensure idempotency since this transaction
// may have been applied previously
// may have been applied previously
);

private final boolean needsIdTracking;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@
<artifact id="org.jboss.xnio:xnio-api:jar:3.3.0.Final">
<license>ASL2.0</license><!-- https://github.com/dmlloyd/xnio/blob/3.x/LICENSE.txt -->
</artifact>
<artifact id="com.google.code.findbugs:annotations:jar:2.0.3">
<license>LGPL2.1</license>
</artifact>
</override-licenses>
<coalesced-licenses>
<license name="Academic Free License version 3.0">
Expand Down

0 comments on commit b1f759a

Please sign in to comment.