com.kuka.nav.battery
Class BatteryLevels.BatteryLevelsBuilder

java.lang.Object
  extended by com.kuka.nav.battery.BatteryLevels.BatteryLevelsBuilder
Enclosing class:
BatteryLevels

public static class BatteryLevels.BatteryLevelsBuilder
extends Object

Builder pattern for creating a valid BatteryLevels configuration. A valid configuration must contain at least one level and all levels must span the range from 0.0 to 1.0 with a threshold value separating levels. Levels are added in sequence from lowest to highest level by passing the upper threshold of the added level. This means that the minimum threshold of 0.0 is implicitly configured and the last level must have an upper threshold of 1.0.


Constructor Summary
BatteryLevels.BatteryLevelsBuilder()
           
 
Method Summary
 BatteryLevels.BatteryLevelsBuilder addLevel(String name, double threshold)
          Adds a new level by passing a name of the level and its upper threshold.
 BatteryLevels.BatteryLevelsBuilder addMaximumLevel(String name)
          Adds the last and highest state of charge level.
 BatteryLevels build()
          Finishes the construction of a BatteryLevels.BatteryLevel instance.
 BatteryLevels.BatteryLevelsBuilder removeLevel()
          Removes the highest configured state of charge level.
 BatteryLevels.BatteryLevelsBuilder setName(String levelName, String newLevelName)
          Changes the name of an already configured level.
 BatteryLevels.BatteryLevelsBuilder setThreshold(String levelName, double newThreshold)
          Changes the upper threshold of the level with the specified name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BatteryLevels.BatteryLevelsBuilder

public BatteryLevels.BatteryLevelsBuilder()
Method Detail

addLevel

public BatteryLevels.BatteryLevelsBuilder addLevel(String name,
                                                   double threshold)
Adds a new level by passing a name of the level and its upper threshold. The lower threshold is the upper threshold of the previous level.

Parameters:
name - a name for the state of charge level
threshold - the upper threshold of the level, must be higher than the threshold of the previous level
Returns:
this builder
Throws:
IllegalArgumentException - if previous threshold is already 1.0 or if the threshold value is larger than 1.0

addMaximumLevel

public BatteryLevels.BatteryLevelsBuilder addMaximumLevel(String name)
Adds the last and highest state of charge level. Same as #addLevel(name, threshold) with a threshold of 1.0.

Parameters:
name - a name for the highest state of charge level
Returns:
this builder

removeLevel

public BatteryLevels.BatteryLevelsBuilder removeLevel()
Removes the highest configured state of charge level.

Returns:
this builder

setThreshold

public BatteryLevels.BatteryLevelsBuilder setThreshold(String levelName,
                                                       double newThreshold)
Changes the upper threshold of the level with the specified name. The new threshold cannot be larger than 1.0 and cannot surpass any successive level.

Parameters:
levelName - the name of level
newThreshold - the new upper threshold of the level
Returns:
this builder

setName

public BatteryLevels.BatteryLevelsBuilder setName(String levelName,
                                                  String newLevelName)
Changes the name of an already configured level.

Parameters:
levelName - the previous name of a level
newLevelName - the new name of the level
Returns:
this builder

build

public BatteryLevels build()
Finishes the construction of a BatteryLevels.BatteryLevel instance.

Returns:
a complete configuration with at least one state of charge level, spanning the complete range from 0.0 to 1.0
Throws:
IllegalStateException - if the configuration is incomplete


Copyright © 2019. All rights reserved.