applied code formatter (#132)

Signed-off-by: Kai Kreuzer <kai@openhab.org>
pull/133/head
Kai Kreuzer 2017-04-07 03:42:37 -07:00 committed by GitHub
parent c8486db1a0
commit 485a65e739
112 changed files with 4853 additions and 4679 deletions

View File

@ -10,7 +10,6 @@ package org.openhab.core.autoupdate;
import org.openhab.core.binding.BindingProvider;
/**
* This interface is implemented by classes that can provide configuration
* information of the AutoUpdate feature.

View File

@ -34,9 +34,9 @@ public class AutoUpdateProviderDelegate implements AutoUpdateBindingConfigProvid
@Override
public Boolean autoUpdate(String itemName) {
for(org.openhab.core.autoupdate.AutoUpdateBindingProvider provider : providers) {
for (org.openhab.core.autoupdate.AutoUpdateBindingProvider provider : providers) {
Boolean autoUpdate = provider.autoUpdate(itemName);
if(autoUpdate!=null) {
if (autoUpdate != null) {
return autoUpdate;
}
}

View File

@ -28,7 +28,7 @@ public abstract class AbstractBinding<P extends BindingProvider> extends Abstrac
/** to keep track of all binding providers */
protected Collection<P> providers = new CopyOnWriteArraySet<P>();
protected Collection<P> providers = new CopyOnWriteArraySet<>();
protected EventPublisher eventPublisher = null;

View File

@ -8,7 +8,6 @@
*/
package org.openhab.core.binding;
/**
* This interface must be implemented by classes which want to be notified by a
* {@link BindingProvider} about changes in the binding configuration.

View File

@ -10,7 +10,6 @@ package org.openhab.core.binding;
import java.util.Collection;
/**
* @author Thomas.Eichstaedt-Engelen
* @author Kai Kreuzer
@ -55,6 +54,7 @@ public interface BindingProvider {
/**
* Returns all items which are mapped to this binding
*
* @return items which are mapped to this binding
*/
Collection<String> getItemNames();

View File

@ -34,13 +34,14 @@ public class BindingConfigReaderFactory {
public void activate(BundleContext context) {
this.context = context;
for(BindingConfigReader reader : readers) {
for (BindingConfigReader reader : readers) {
registerDelegateService(reader);
}
}
public void deactivate() {
for(ServiceRegistration<org.eclipse.smarthome.model.item.BindingConfigReader> serviceReg : delegates.values()) {
for (ServiceRegistration<org.eclipse.smarthome.model.item.BindingConfigReader> serviceReg : delegates
.values()) {
serviceReg.unregister();
}
delegates.clear();
@ -48,7 +49,7 @@ public class BindingConfigReaderFactory {
}
public void addBindingConfigReader(BindingConfigReader reader) {
if(context!=null) {
if (context != null) {
registerDelegateService(reader);
} else {
readers.add(reader);
@ -56,25 +57,25 @@ public class BindingConfigReaderFactory {
}
public void removeBindingConfigReader(BindingConfigReader reader) {
if(context!=null) {
if (context != null) {
unregisterDelegateService(reader);
}
}
private void registerDelegateService(BindingConfigReader reader) {
if(!delegates.containsKey(reader.getBindingType())) {
if (!delegates.containsKey(reader.getBindingType())) {
BindingConfigReaderDelegate service = new BindingConfigReaderDelegate(reader);
Dictionary<String, Object> props = new Hashtable<String, Object>();
ServiceRegistration<org.eclipse.smarthome.model.item.BindingConfigReader> serviceReg =
context.registerService(org.eclipse.smarthome.model.item.BindingConfigReader.class, service, props);
Dictionary<String, Object> props = new Hashtable<>();
ServiceRegistration<org.eclipse.smarthome.model.item.BindingConfigReader> serviceReg = context
.registerService(org.eclipse.smarthome.model.item.BindingConfigReader.class, service, props);
delegates.put(reader.getBindingType(), serviceReg);
}
}
private void unregisterDelegateService(BindingConfigReader reader) {
if(delegates.containsKey(reader.getBindingType())) {
ServiceRegistration<org.eclipse.smarthome.model.item.BindingConfigReader> serviceReg =
delegates.get(reader.getBindingType());
if (delegates.containsKey(reader.getBindingType())) {
ServiceRegistration<org.eclipse.smarthome.model.item.BindingConfigReader> serviceReg = delegates
.get(reader.getBindingType());
delegates.remove(reader.getBindingType());
serviceReg.unregister();
}

View File

@ -36,14 +36,14 @@ public class CompatibilityActivator implements BundleActivator {
public void start(BundleContext bundleContext) throws Exception {
CompatibilityActivator.context = bundleContext;
itemRegistryTracker = new ServiceTracker<ItemRegistry, ItemRegistry>(bundleContext, ItemRegistry.class, null);
itemRegistryTracker = new ServiceTracker<>(bundleContext, ItemRegistry.class, null);
itemRegistryTracker.open();
eventPublisherTracker = new ServiceTracker<EventPublisher, EventPublisher>(bundleContext, EventPublisher.class,
eventPublisherTracker = new ServiceTracker<>(bundleContext, EventPublisher.class,
null);
eventPublisherTracker.open();
scriptEngineTracker = new ServiceTracker<ScriptEngine, ScriptEngine>(bundleContext, ScriptEngine.class, null);
scriptEngineTracker = new ServiceTracker<>(bundleContext, ScriptEngine.class, null);
scriptEngineTracker.open();
}

View File

@ -8,12 +8,11 @@
*/
package org.openhab.core.events;
import static org.openhab.core.events.EventConstants.TOPIC_PREFIX;
import static org.openhab.core.events.EventConstants.TOPIC_SEPERATOR;
import static org.openhab.core.events.EventConstants.*;
import org.openhab.core.types.Command;
import org.openhab.core.types.State;
import org.openhab.core.types.EventType;
import org.openhab.core.types.State;
import org.osgi.service.event.Event;
import org.osgi.service.event.EventHandler;
@ -22,24 +21,29 @@ abstract public class AbstractEventSubscriber implements EventHandler {
/**
* {@inheritDoc}
*/
@Override
public void handleEvent(Event event) {
String itemName = (String) event.getProperty("item");
String topic = event.getTopic();
String[] topicParts = topic.split(TOPIC_SEPERATOR);
if(!(topicParts.length > 2) || !topicParts[0].equals(TOPIC_PREFIX)) {
if (!(topicParts.length > 2) || !topicParts[0].equals(TOPIC_PREFIX)) {
return; // we have received an event with an invalid topic
}
String operation = topicParts[1];
if(operation.equals(EventType.UPDATE.toString())) {
if (operation.equals(EventType.UPDATE.toString())) {
State newState = (State) event.getProperty("state");
if(newState!=null) receiveUpdate(itemName, newState);
if (newState != null) {
receiveUpdate(itemName, newState);
}
if(operation.equals(EventType.COMMAND.toString())) {
}
if (operation.equals(EventType.COMMAND.toString())) {
Command command = (Command) event.getProperty("command");
if(command!=null) receiveCommand(itemName, command);
if (command != null) {
receiveCommand(itemName, command);
}
}
}

View File

@ -86,21 +86,21 @@ public class EventBridge implements EventHandler, EventSubscriber {
Map<String, Object> properties = new HashMap<>();
if (event instanceof ItemCommandEvent) {
ItemCommandEvent icEvent = (ItemCommandEvent) event;
String itemName = (String) icEvent.getItemName();
String itemName = icEvent.getItemName();
properties.put("item", itemName);
Type eshType = TypeMapper.mapToOpenHABType(icEvent.getItemCommand());
if (eshType instanceof Command) {
properties.put("command", (Command) eshType);
properties.put("command", eshType);
} else {
return null;
}
} else {
ItemStateEvent isEvent = (ItemStateEvent) event;
String itemName = (String) isEvent.getItemName();
String itemName = isEvent.getItemName();
properties.put("item", itemName);
Type eshType = TypeMapper.mapToOpenHABType(isEvent.getItemState());
if (eshType instanceof State) {
properties.put("state", (State) eshType);
properties.put("state", eshType);
} else {
return null;
}

View File

@ -33,9 +33,10 @@ abstract public class GenericItem implements Item {
protected EventPublisher eventPublisher;
protected Set<StateChangeListener> listeners = new CopyOnWriteArraySet<StateChangeListener>(Collections.newSetFromMap(new WeakHashMap<StateChangeListener, Boolean>()));
protected Set<StateChangeListener> listeners = new CopyOnWriteArraySet<>(
Collections.newSetFromMap(new WeakHashMap<StateChangeListener, Boolean>()));
protected List<String> groupNames = new ArrayList<String>();
protected List<String> groupNames = new ArrayList<>();
final protected String name;
@ -48,6 +49,7 @@ abstract public class GenericItem implements Item {
/**
* {@inheritDoc}
*/
@Override
public State getState() {
return state;
}
@ -55,15 +57,17 @@ abstract public class GenericItem implements Item {
/**
* {@inheritDoc}
*/
@Override
public State getStateAs(Class<? extends State> typeClass) {
if(typeClass!=null && typeClass.isInstance(state)) {
if (typeClass != null && typeClass.isInstance(state)) {
return state;
} else {
return null;
}
}
public void initialize() {}
public void initialize() {
}
public void dispose() {
this.eventPublisher = null;
@ -72,6 +76,7 @@ abstract public class GenericItem implements Item {
/**
* {@inheritDoc}
*/
@Override
public String getName() {
return name;
}
@ -79,6 +84,7 @@ abstract public class GenericItem implements Item {
/**
* {@inheritDoc}
*/
@Override
public List<String> getGroupNames() {
return groupNames;
}
@ -89,7 +95,7 @@ abstract public class GenericItem implements Item {
protected void internalSend(Command command) {
// try to send the command to the bus
if(eventPublisher!=null) {
if (eventPublisher != null) {
eventPublisher.sendCommand(this.getName(), command);
}
}
@ -103,12 +109,12 @@ abstract public class GenericItem implements Item {
private void notifyListeners(State oldState, State newState) {
// if nothing has changed, we send update notifications
Set<StateChangeListener> clonedListeners = null;
clonedListeners = new CopyOnWriteArraySet<StateChangeListener>(listeners);
for(StateChangeListener listener : clonedListeners) {
clonedListeners = new CopyOnWriteArraySet<>(listeners);
for (StateChangeListener listener : clonedListeners) {
listener.stateUpdated(this, newState);
}
if(!oldState.equals(newState)) {
for(StateChangeListener listener : clonedListeners) {
if (!oldState.equals(newState)) {
for (StateChangeListener listener : clonedListeners) {
listener.stateChanged(this, oldState, newState);
}
}
@ -119,24 +125,21 @@ abstract public class GenericItem implements Item {
*/
@Override
public String toString() {
return getName() + " (" +
"Type=" + getClass().getSimpleName() + ", " +
"State=" + getState() + ")";
return getName() + " (" + "Type=" + getClass().getSimpleName() + ", " + "State=" + getState() + ")";
}
public void addStateChangeListener(StateChangeListener listener) {
synchronized(listeners) {
synchronized (listeners) {
listeners.add(listener);
}
}
public void removeStateChangeListener(StateChangeListener listener) {
synchronized(listeners) {
synchronized (listeners) {
listeners.remove(listener);
}
}
@Override
public int hashCode() {
final int prime = 31;
@ -149,30 +152,38 @@ abstract public class GenericItem implements Item {
@Override
public boolean equals(Object obj) {
if (this == obj)
if (this == obj) {
return true;
if (obj == null)
}
if (obj == null) {
return false;
if (getClass() != obj.getClass())
}
if (getClass() != obj.getClass()) {
return false;
}
GenericItem other = (GenericItem) obj;
if (groupNames == null) {
if (other.groupNames != null)
if (other.groupNames != null) {
return false;
} else if (!groupNames.equals(other.groupNames))
}
} else if (!groupNames.equals(other.groupNames)) {
return false;
}
if (name == null) {
if (other.name != null)
if (other.name != null) {
return false;
} else if (!name.equals(other.name))
}
} else if (!name.equals(other.name)) {
return false;
}
if (state == null) {
if (other.state != null)
if (other.state != null) {
return false;
} else if (!state.equals(other.state))
}
} else if (!state.equals(other.state)) {
return false;
}
return true;
}
}

View File

@ -53,11 +53,12 @@ abstract public interface GroupFunction {
/**
* @{inheritDoc
*/
@Override
public State calculate(List<Item> items) {
if(items.size()>0) {
if (items.size() > 0) {
State state = items.get(0).getState();
for(int i=1; i<items.size(); i++) {
if(!state.equals(items.get(i).getState())) {
for (int i = 1; i < items.size(); i++) {
if (!state.equals(items.get(i).getState())) {
return UnDefType.UNDEF;
}
}
@ -70,10 +71,10 @@ abstract public interface GroupFunction {
/**
* @{inheritDoc
*/
public State getStateAs(List<Item> items,
Class<? extends State> stateClass) {
@Override
public State getStateAs(List<Item> items, Class<? extends State> stateClass) {
State state = calculate(items);
if(stateClass.isInstance(state)) {
if (stateClass.isInstance(state)) {
return state;
} else {
return null;

View File

@ -40,7 +40,7 @@ public class GroupItem extends GenericItem implements StateChangeListener {
public GroupItem(String name, GenericItem baseItem, GroupFunction function) {
super(name);
members = new CopyOnWriteArrayList<Item>();
members = new CopyOnWriteArrayList<>();
this.function = function;
this.baseItem = baseItem;
}
@ -74,17 +74,16 @@ public class GroupItem extends GenericItem implements StateChangeListener {
* @return all members of this and all contained {@link GroupItem}s
*/
public List<Item> getAllMembers() {
Set<Item> allMembers = new HashSet<Item>();
Set<Item> allMembers = new HashSet<>();
collectMembers(allMembers, members);
return new ArrayList<Item>(allMembers);
return new ArrayList<>(allMembers);
}
private void collectMembers(Set<Item> allMembers, List<Item> members) {
for (Item member : members) {
if (member instanceof GroupItem) {
collectMembers(allMembers, ((GroupItem) member).members);
}
else {
} else {
allMembers.add(member);
}
}
@ -113,15 +112,16 @@ public class GroupItem extends GenericItem implements StateChangeListener {
*
* @return the accepted data types of this group item
*/
@Override
@SuppressWarnings("unchecked")
public List<Class<? extends State>> getAcceptedDataTypes() {
if(baseItem!=null) {
if (baseItem != null) {
return baseItem.getAcceptedDataTypes();
} else {
List<Class<? extends State>> acceptedDataTypes = null;
for(Item item : members) {
if(acceptedDataTypes==null) {
for (Item item : members) {
if (acceptedDataTypes == null) {
acceptedDataTypes = item.getAcceptedDataTypes();
} else {
acceptedDataTypes = ListUtils.intersection(acceptedDataTypes, item.getAcceptedDataTypes());
@ -138,15 +138,16 @@ public class GroupItem extends GenericItem implements StateChangeListener {
*
* @return the accepted command types of this group item
*/
@Override
@SuppressWarnings("unchecked")
public List<Class<? extends Command>> getAcceptedCommandTypes() {
if(baseItem!=null) {
if (baseItem != null) {
return baseItem.getAcceptedCommandTypes();
} else {
List<Class<? extends Command>> acceptedCommandTypes = null;
for(Item item : members) {
if(acceptedCommandTypes==null) {
for (Item item : members) {
if (acceptedCommandTypes == null) {
acceptedCommandTypes = item.getAcceptedCommandTypes();
} else {
acceptedCommandTypes = ListUtils.intersection(acceptedCommandTypes, item.getAcceptedCommandTypes());
@ -157,10 +158,11 @@ public class GroupItem extends GenericItem implements StateChangeListener {
}
public void send(Command command) {
if(getAcceptedCommandTypes().contains(command.getClass())) {
if (getAcceptedCommandTypes().contains(command.getClass())) {
internalSend(command);
} else {
logger.warn("Command '{}' has been ignored for group '{}' as it is not accepted.", command.toString(), getName());
logger.warn("Command '{}' has been ignored for group '{}' as it is not accepted.", command.toString(),
getName());
}
}
@ -169,8 +171,8 @@ public class GroupItem extends GenericItem implements StateChangeListener {
*/
@Override
protected void internalSend(Command command) {
if(eventPublisher!=null) {
for(Item member : members) {
if (eventPublisher != null) {
for (Item member : members) {
// try to send the command to the bus
eventPublisher.sendCommand(member.getName(), command);
}
@ -183,12 +185,12 @@ public class GroupItem extends GenericItem implements StateChangeListener {
@Override
public State getStateAs(Class<? extends State> typeClass) {
State newState = function.getStateAs(getAllMembers(), typeClass);
if(newState==null && baseItem!=null) {
if (newState == null && baseItem != null) {
// we use the transformation method from the base item
baseItem.setState(state);
newState = baseItem.getStateAs(typeClass);
}
if(newState==null) {
if (newState == null) {
newState = super.getStateAs(typeClass);
}
return newState;
@ -199,16 +201,15 @@ public class GroupItem extends GenericItem implements StateChangeListener {
*/
@Override
public String toString() {
return getName() + " (" +
"Type=" + getClass().getSimpleName() + ", " +
(baseItem != null ? "BaseType=" + baseItem.getClass().getSimpleName() + ", " : "") +
"Members=" + members.size() + ", " +
"State=" + getState() + ")";
return getName() + " (" + "Type=" + getClass().getSimpleName() + ", "
+ (baseItem != null ? "BaseType=" + baseItem.getClass().getSimpleName() + ", " : "") + "Members="
+ members.size() + ", " + "State=" + getState() + ")";
}
/**
* @{inheritDoc
*/
@Override
public void stateChanged(Item item, State oldState, State newState) {
setState(function.calculate(members));
}
@ -216,6 +217,7 @@ public class GroupItem extends GenericItem implements StateChangeListener {
/**
* @{inheritDoc
*/
@Override
public void stateUpdated(Item item, State state) {
setState(function.calculate(members));
}

View File

@ -14,9 +14,13 @@ import org.openhab.core.types.Command;
import org.openhab.core.types.State;
/**
* <p>This interface defines the core features of an openHAB item.</p>
* <p>Item instances are used for all stateful services and are especially
* important for the {@link ItemRegistry}.</p>
* <p>
* This interface defines the core features of an openHAB item.
* </p>
* <p>
* Item instances are used for all stateful services and are especially
* important for the {@link ItemRegistry}.
* </p>
*
* @author Kai Kreuzer
*
@ -46,21 +50,28 @@ public interface Item {
public String getName();
/**
* <p>This method provides a list of all data types that can be used to update the item state</p>
* <p>Imagine e.g. a dimmer device: It's status could be 0%, 10%, 50%, 100%, but also OFF or ON and
* <p>
* This method provides a list of all data types that can be used to update the item state
* </p>
* <p>
* Imagine e.g. a dimmer device: It's status could be 0%, 10%, 50%, 100%, but also OFF or ON and
* maybe UNDEFINED. So the accepted data types would be in this case {@link PercentType}, {@link OnOffType}
* and {@link UnDefType}</p>
* and {@link UnDefType}
* </p>
*
* @return a list of data types that can be used to update the item state
*/
public List<Class<? extends State>> getAcceptedDataTypes();
/**
* <p>This method provides a list of all command types that can be used for this item</p>
* <p>Imagine e.g. a dimmer device: You could ask it to dim to 0%, 10%, 50%, 100%, but
* <p>
* This method provides a list of all command types that can be used for this item
* </p>
* <p>
* Imagine e.g. a dimmer device: You could ask it to dim to 0%, 10%, 50%, 100%, but
* also to turn OFF or ON. So the accepted command types would be in this case {@link PercentType},
* {@link OnOffType}</p>
* {@link OnOffType}
* </p>
*
* @return a list of all command types that can be used for this item
*/

View File

@ -8,7 +8,6 @@
*/
package org.openhab.core.items;
/**
* This Factory creates concrete instances of the known ItemTypes.
*

View File

@ -11,10 +11,14 @@ package org.openhab.core.items;
import org.openhab.core.types.State;
/**
* <p>This interface must be implemented by all classes that want to be notified
* about changes in the state of an item.</p>
* <p>The {@link GenericItem} class provides the possibility to register such
* listeners.</p>
* <p>
* This interface must be implemented by all classes that want to be notified
* about changes in the state of an item.
* </p>
* <p>
* The {@link GenericItem} class provides the possibility to register such
* listeners.
* </p>
*
* @author Kai Kreuzer
*

View File

@ -68,7 +68,7 @@ public class ItemUIRegistryDelegate
@Override
public Collection<Item> getItems() {
Collection<org.eclipse.smarthome.core.items.Item> eshItems = itemUIRegistry.getItems();
Collection<Item> ohItems = new HashSet<Item>(eshItems.size());
Collection<Item> ohItems = new HashSet<>(eshItems.size());
for (org.eclipse.smarthome.core.items.Item eshItem : eshItems) {
ohItems.add(ItemMapper.mapToOpenHABItem(eshItem));
@ -79,7 +79,7 @@ public class ItemUIRegistryDelegate
@Override
public Collection<Item> getItems(String pattern) {
Collection<org.eclipse.smarthome.core.items.Item> eshItems = itemUIRegistry.getItems(pattern);
Collection<Item> ohItems = new HashSet<Item>(eshItems.size());
Collection<Item> ohItems = new HashSet<>(eshItems.size());
for (org.eclipse.smarthome.core.items.Item eshItem : eshItems) {
ohItems.add(ItemMapper.mapToOpenHABItem(eshItem));

View File

@ -28,10 +28,11 @@ import org.openhab.core.types.UnDefType;
* @author Kai Kreuzer
* @since 1.2.0
*
*/public class ColorItem extends DimmerItem {
*/
public class ColorItem extends DimmerItem {
private static List<Class<? extends State>> acceptedDataTypes = new ArrayList<Class<? extends State>>();
private static List<Class<? extends Command>> acceptedCommandTypes = new ArrayList<Class<? extends Command>>();
private static List<Class<? extends State>> acceptedDataTypes = new ArrayList<>();
private static List<Class<? extends Command>> acceptedCommandTypes = new ArrayList<>();
static {
acceptedDataTypes.add(OnOffType.class);
@ -53,10 +54,12 @@ import org.openhab.core.types.UnDefType;
internalSend(command);
}
@Override
public List<Class<? extends State>> getAcceptedDataTypes() {
return acceptedDataTypes;
}
@Override
public List<Class<? extends Command>> getAcceptedCommandTypes() {
return acceptedCommandTypes;
}
@ -68,26 +71,26 @@ import org.openhab.core.types.UnDefType;
public void setState(State state) {
State currentState = this.state;
if(currentState instanceof HSBType) {
if (currentState instanceof HSBType) {
DecimalType hue = ((HSBType) currentState).getHue();
PercentType saturation = ((HSBType) currentState).getSaturation();
// we map ON/OFF values to dark/bright, so that the hue and saturation values are not changed
if(state==OnOffType.OFF) {
if (state == OnOffType.OFF) {
super.setState(new HSBType(hue, saturation, PercentType.ZERO));
} else if(state==OnOffType.ON) {
} else if (state == OnOffType.ON) {
super.setState(new HSBType(hue, saturation, PercentType.HUNDRED));
} else if(state instanceof PercentType && !(state instanceof HSBType)) {
} else if (state instanceof PercentType && !(state instanceof HSBType)) {
super.setState(new HSBType(hue, saturation, (PercentType) state));
} else {
super.setState(state);
}
} else {
// we map ON/OFF values to black/white and percentage values to grey scale
if(state==OnOffType.OFF) {
if (state == OnOffType.OFF) {
super.setState(HSBType.BLACK);
} else if(state==OnOffType.ON) {
} else if (state == OnOffType.ON) {
super.setState(HSBType.WHITE);
} else if(state instanceof PercentType && !(state instanceof HSBType)) {
} else if (state instanceof PercentType && !(state instanceof HSBType)) {
super.setState(new HSBType(DecimalType.ZERO, PercentType.ZERO, (PercentType) state));
} else {
super.setState(state);
@ -100,18 +103,19 @@ import org.openhab.core.types.UnDefType;
*/
@Override
public State getStateAs(Class<? extends State> typeClass) {
if(typeClass==HSBType.class) {
if (typeClass == HSBType.class) {
return this.state;
} else if(typeClass==OnOffType.class) {
if(state instanceof HSBType) {
} else if (typeClass == OnOffType.class) {
if (state instanceof HSBType) {
HSBType hsbState = (HSBType) state;
// if brightness is not completely off, we consider the state to be on
return hsbState.getBrightness().equals(PercentType.ZERO) ? OnOffType.OFF : OnOffType.ON;
}
} else if(typeClass==DecimalType.class) {
if(state instanceof HSBType) {
} else if (typeClass == DecimalType.class) {
if (state instanceof HSBType) {
HSBType hsbState = (HSBType) state;
return new DecimalType(hsbState.getBrightness().toBigDecimal().divide(new BigDecimal(100), 8, RoundingMode.UP));
return new DecimalType(
hsbState.getBrightness().toBigDecimal().divide(new BigDecimal(100), 8, RoundingMode.UP));
}
}
return super.getStateAs(typeClass);

View File

@ -29,8 +29,8 @@ import org.openhab.core.types.UnDefType;
*/
public class ContactItem extends GenericItem {
private static List<Class<? extends State>> acceptedDataTypes = new ArrayList<Class<? extends State>>();
private static List<Class<? extends Command>> acceptedCommandTypes = new ArrayList<Class<? extends Command>>();
private static List<Class<? extends State>> acceptedDataTypes = new ArrayList<>();
private static List<Class<? extends Command>> acceptedCommandTypes = new ArrayList<>();
static {
acceptedDataTypes.add(OpenClosedType.class);
@ -45,10 +45,12 @@ public class ContactItem extends GenericItem {
internalSend(command);
}
@Override
public List<Class<? extends State>> getAcceptedDataTypes() {
return acceptedDataTypes;
}
@Override
public List<Class<? extends Command>> getAcceptedCommandTypes() {
return acceptedCommandTypes;
}
@ -58,10 +60,10 @@ public class ContactItem extends GenericItem {
*/
@Override
public State getStateAs(Class<? extends State> typeClass) {
if(typeClass==DecimalType.class) {
return state==OpenClosedType.OPEN ? new DecimalType(1) : DecimalType.ZERO;
} else if(typeClass==PercentType.class) {
return state==OpenClosedType.OPEN ? PercentType.HUNDRED : PercentType.ZERO;
if (typeClass == DecimalType.class) {
return state == OpenClosedType.OPEN ? new DecimalType(1) : DecimalType.ZERO;
} else if (typeClass == PercentType.class) {
return state == OpenClosedType.OPEN ? PercentType.HUNDRED : PercentType.ZERO;
} else {
return super.getStateAs(typeClass);
}

View File

@ -27,8 +27,8 @@ import org.openhab.core.types.UnDefType;
*/
public class DateTimeItem extends GenericItem {
private static List<Class<? extends State>> acceptedDataTypes = new ArrayList<Class<? extends State>>();
private static List<Class<? extends Command>> acceptedCommandTypes = new ArrayList<Class<? extends Command>>();
private static List<Class<? extends State>> acceptedDataTypes = new ArrayList<>();
private static List<Class<? extends Command>> acceptedCommandTypes = new ArrayList<>();
static {
acceptedDataTypes.add((DateTimeType.class));
@ -39,10 +39,12 @@ public class DateTimeItem extends GenericItem {
super(name);
}
@Override
public List<Class<? extends State>> getAcceptedDataTypes() {
return acceptedDataTypes;
}
@Override
public List<Class<? extends Command>> getAcceptedCommandTypes() {
return acceptedCommandTypes;
}

View File

@ -31,8 +31,8 @@ import org.openhab.core.types.UnDefType;
*/
public class DimmerItem extends SwitchItem {
private static List<Class<? extends State>> acceptedDataTypes = new ArrayList<Class<? extends State>>();
private static List<Class<? extends Command>> acceptedCommandTypes = new ArrayList<Class<? extends Command>>();
private static List<Class<? extends State>> acceptedDataTypes = new ArrayList<>();
private static List<Class<? extends Command>> acceptedCommandTypes = new ArrayList<>();
static {
acceptedDataTypes.add(OnOffType.class);
@ -52,10 +52,12 @@ public class DimmerItem extends SwitchItem {
internalSend(command);
}
@Override
public List<Class<? extends State>> getAcceptedDataTypes() {
return acceptedDataTypes;
}
@Override
public List<Class<? extends Command>> getAcceptedCommandTypes() {
return acceptedCommandTypes;
}
@ -66,9 +68,9 @@ public class DimmerItem extends SwitchItem {
@Override
public void setState(State state) {
// we map ON/OFF values to the percent values 0 and 100
if(state==OnOffType.OFF) {
if (state == OnOffType.OFF) {
super.setState(PercentType.ZERO);
} else if(state==OnOffType.ON) {
} else if (state == OnOffType.ON) {
super.setState(PercentType.HUNDRED);
} else {
super.setState(state);

View File

@ -26,8 +26,8 @@ import org.openhab.core.types.UnDefType;
* @since 1.7.0
*/
public class LocationItem extends GenericItem {
private static List<Class<? extends State>> acceptedDataTypes = new ArrayList<Class<? extends State>>();
private static List<Class<? extends Command>> acceptedCommandTypes = new ArrayList<Class<? extends Command>>();
private static List<Class<? extends State>> acceptedDataTypes = new ArrayList<>();
private static List<Class<? extends Command>> acceptedCommandTypes = new ArrayList<>();
static {
acceptedDataTypes.add(PointType.class);
@ -38,10 +38,12 @@ public class LocationItem extends GenericItem {
super(name);
}
@Override
public List<Class<? extends State>> getAcceptedDataTypes() {
return acceptedDataTypes;
}
@Override
public List<Class<? extends Command>> getAcceptedCommandTypes() {
return acceptedCommandTypes;
}
@ -49,9 +51,10 @@ public class LocationItem extends GenericItem {
/**
* Compute the distance with another Point type,
* http://stackoverflow.com/questions/837872/calculate-distance-in-meters-when-you-know-longitude-and-latitude-in-java
*
* @return distance between the two points in meters
*/
public DecimalType distanceFrom(PointType away){
public DecimalType distanceFrom(PointType away) {
double dist = -1;
@ -59,12 +62,15 @@ public class LocationItem extends GenericItem {
PointType me = (PointType) this.state;
double dLat = Math.pow(Math.sin(Math.toRadians(away.getLatitude().doubleValue() - me.getLatitude().doubleValue()) / 2),2);
double dLng = Math.pow(Math.sin(Math.toRadians(away.getLongitude().doubleValue() - me.getLongitude().doubleValue()) / 2),2);
double dLat = Math.pow(
Math.sin(Math.toRadians(away.getLatitude().doubleValue() - me.getLatitude().doubleValue()) / 2), 2);
double dLng = Math.pow(
Math.sin(Math.toRadians(away.getLongitude().doubleValue() - me.getLongitude().doubleValue()) / 2),
2);
double a = dLat + Math.cos(Math.toRadians(me.getLatitude().doubleValue()))
* Math.cos(Math.toRadians(away.getLatitude().doubleValue())) * dLng;
dist = PointType.WGS84_a * 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
dist = PointType.WGS84_a * 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
}
return new DecimalType(dist);

View File

@ -29,8 +29,8 @@ import org.openhab.core.types.UnDefType;
*/
public class NumberItem extends GenericItem {
private static List<Class<? extends State>> acceptedDataTypes = new ArrayList<Class<? extends State>>();
private static List<Class<? extends Command>> acceptedCommandTypes = new ArrayList<Class<? extends Command>>();
private static List<Class<? extends State>> acceptedDataTypes = new ArrayList<>();
private static List<Class<? extends Command>> acceptedCommandTypes = new ArrayList<>();
static {
acceptedDataTypes.add(DecimalType.class);
@ -43,10 +43,12 @@ public class NumberItem extends GenericItem {
super(name);
}
@Override
public List<Class<? extends State>> getAcceptedDataTypes() {
return acceptedDataTypes;
}
@Override
public List<Class<? extends Command>> getAcceptedCommandTypes() {
return acceptedCommandTypes;
}

View File

@ -31,8 +31,8 @@ import org.openhab.core.types.UnDefType;
*/
public class RollershutterItem extends GenericItem {
private static List<Class<? extends State>> acceptedDataTypes = new ArrayList<Class<? extends State>>();
private static List<Class<? extends Command>> acceptedCommandTypes = new ArrayList<Class<? extends Command>>();
private static List<Class<? extends State>> acceptedDataTypes = new ArrayList<>();
private static List<Class<? extends Command>> acceptedCommandTypes = new ArrayList<>();
static {
acceptedDataTypes.add(UnDefType.class);
@ -48,10 +48,12 @@ public class RollershutterItem extends GenericItem {
super(name);
}
@Override
public List<Class<? extends State>> getAcceptedDataTypes() {
return acceptedDataTypes;
}
@Override
public List<Class<? extends Command>> getAcceptedCommandTypes() {
return acceptedCommandTypes;
}
@ -62,9 +64,9 @@ public class RollershutterItem extends GenericItem {
@Override
public void setState(State state) {
// we map UP/DOWN values to the percent values 0 and 100
if(state==UpDownType.UP) {
if (state == UpDownType.UP) {
super.setState(PercentType.ZERO);
} else if(state==UpDownType.DOWN) {
} else if (state == UpDownType.DOWN) {
super.setState(PercentType.HUNDRED);
} else {
super.setState(state);
@ -76,17 +78,18 @@ public class RollershutterItem extends GenericItem {
*/
@Override
public State getStateAs(Class<? extends State> typeClass) {
if(typeClass==UpDownType.class) {
if(state.equals(PercentType.ZERO)) {
if (typeClass == UpDownType.class) {
if (state.equals(PercentType.ZERO)) {
return UpDownType.UP;
} else if(state.equals(PercentType.HUNDRED)) {
} else if (state.equals(PercentType.HUNDRED)) {
return UpDownType.DOWN;
} else {
return UnDefType.UNDEF;
}
} else if(typeClass==DecimalType.class) {
if(state instanceof PercentType) {
return new DecimalType(((PercentType) state).toBigDecimal().divide(new BigDecimal(100), 8, RoundingMode.UP));
} else if (typeClass == DecimalType.class) {
if (state instanceof PercentType) {
return new DecimalType(
((PercentType) state).toBigDecimal().divide(new BigDecimal(100), 8, RoundingMode.UP));
}
}
return super.getStateAs(typeClass);

View File

@ -29,8 +29,8 @@ import org.openhab.core.types.UnDefType;
*/
public class StringItem extends GenericItem {
private static List<Class<? extends State>> acceptedDataTypes = new ArrayList<Class<? extends State>>();
private static List<Class<? extends Command>> acceptedCommandTypes = new ArrayList<Class<? extends Command>>();
private static List<Class<? extends State>> acceptedDataTypes = new ArrayList<>();
private static List<Class<? extends Command>> acceptedCommandTypes = new ArrayList<>();
static {
acceptedDataTypes.add(StringType.class);
@ -44,20 +44,22 @@ public class StringItem extends GenericItem {
super(name);
}
@Override
public List<Class<? extends State>> getAcceptedDataTypes() {
return acceptedDataTypes;
}
@Override
public List<Class<? extends Command>> getAcceptedCommandTypes() {
return acceptedCommandTypes;
}
@Override
public State getStateAs(Class<? extends State> typeClass) {
ArrayList<Class<? extends State>> list = new ArrayList<Class<? extends State>>();
ArrayList<Class<? extends State>> list = new ArrayList<>();
list.add(typeClass);
State convertedState = TypeParser.parseState(list, state.toString());
if(convertedState!=null) {
if (convertedState != null) {
return convertedState;
} else {
return super.getStateAs(typeClass);

View File

@ -29,8 +29,8 @@ import org.openhab.core.types.UnDefType;
*/
public class SwitchItem extends GenericItem {
private static List<Class<? extends State>> acceptedDataTypes = new ArrayList<Class<? extends State>>();
private static List<Class<? extends Command>> acceptedCommandTypes = new ArrayList<Class<? extends Command>>();
private static List<Class<? extends State>> acceptedDataTypes = new ArrayList<>();
private static List<Class<? extends Command>> acceptedCommandTypes = new ArrayList<>();
static {
acceptedDataTypes.add(OnOffType.class);
@ -47,20 +47,22 @@ public class SwitchItem extends GenericItem {
internalSend(command);
}
@Override
public List<Class<? extends State>> getAcceptedDataTypes() {
return acceptedDataTypes;
}
@Override
public List<Class<? extends Command>> getAcceptedCommandTypes() {
return acceptedCommandTypes;
}
@Override
public State getStateAs(Class<? extends State> typeClass) {
if(typeClass==DecimalType.class) {
return state==OnOffType.ON ? new DecimalType(1) : DecimalType.ZERO;
} else if(typeClass==PercentType.class) {
return state==OnOffType.ON ? PercentType.HUNDRED : PercentType.ZERO;
if (typeClass == DecimalType.class) {
return state == OnOffType.ON ? new DecimalType(1) : DecimalType.ZERO;
} else if (typeClass == PercentType.class) {
return state == OnOffType.ON ? PercentType.HUNDRED : PercentType.ZERO;
} else {
return super.getStateAs(typeClass);
}

View File

@ -44,7 +44,7 @@ public interface ArithmeticGroupFunction extends GroupFunction {
protected final State passiveState;
public And(State activeValue, State passiveValue) {
if(activeValue==null || passiveValue==null) {
if (activeValue == null || passiveValue == null) {
throw new IllegalArgumentException("Parameters must not be null!");
}
this.activeState = activeValue;
@ -54,10 +54,11 @@ public interface ArithmeticGroupFunction extends GroupFunction {
/**
* @{inheritDoc
*/
@Override
public State calculate(List<Item> items) {
if(items!=null && items.size()>0) {
for(Item item : items) {
if(!activeState.equals(item.getStateAs(activeState.getClass()))) {
if (items != null && items.size() > 0) {
for (Item item : items) {
if (!activeState.equals(item.getStateAs(activeState.getClass()))) {
return passiveState;
}
}
@ -71,13 +72,14 @@ public interface ArithmeticGroupFunction extends GroupFunction {
/**
* @{inheritDoc
*/
@Override
public State getStateAs(List<Item> items, Class<? extends State> stateClass) {
State state = calculate(items);
if(stateClass.isInstance(state)) {
if (stateClass.isInstance(state)) {
return state;
} else {
if(stateClass == DecimalType.class) {
if(items!=null) {
if (stateClass == DecimalType.class) {
if (items != null) {
return new DecimalType(items.size() - count(items, activeState));
} else {
return DecimalType.ZERO;
@ -90,9 +92,9 @@ public interface ArithmeticGroupFunction extends GroupFunction {
private int count(List<Item> items, State state) {
int count = 0;
if(items!=null && state!=null) {
for(Item item : items) {
if(state.equals(item.getStateAs(state.getClass()))) {
if (items != null && state != null) {
for (Item item : items) {
if (state.equals(item.getStateAs(state.getClass()))) {
count++;
}
}
@ -119,7 +121,7 @@ public interface ArithmeticGroupFunction extends GroupFunction {
protected final State passiveState;
public Or(State activeValue, State passiveValue) {
if(activeValue==null || passiveValue==null) {
if (activeValue == null || passiveValue == null) {
throw new IllegalArgumentException("Parameters must not be null!");
}
this.activeState = activeValue;
@ -129,10 +131,11 @@ public interface ArithmeticGroupFunction extends GroupFunction {
/**
* @{inheritDoc
*/
@Override
public State calculate(List<Item> items) {
if(items!=null) {
for(Item item : items) {
if(activeState.equals(item.getStateAs(activeState.getClass()))) {
if (items != null) {
for (Item item : items) {
if (activeState.equals(item.getStateAs(activeState.getClass()))) {
return activeState;
}
}
@ -143,12 +146,13 @@ public interface ArithmeticGroupFunction extends GroupFunction {
/**
* @{inheritDoc
*/
@Override
public State getStateAs(List<Item> items, Class<? extends State> stateClass) {
State state = calculate(items);
if(stateClass.isInstance(state)) {
if (stateClass.isInstance(state)) {
return state;
} else {
if(stateClass == DecimalType.class) {
if (stateClass == DecimalType.class) {
return new DecimalType(count(items, activeState));
} else {
return null;
@ -158,9 +162,9 @@ public interface ArithmeticGroupFunction extends GroupFunction {
private int count(List<Item> items, State state) {
int count = 0;
if(items!=null && state!=null) {
for(Item item : items) {
if(state.equals(item.getStateAs(state.getClass()))) {
if (items != null && state != null) {
for (Item item : items) {
if (state.equals(item.getStateAs(state.getClass()))) {
count++;
}
}
@ -184,10 +188,10 @@ public interface ArithmeticGroupFunction extends GroupFunction {
super(activeValue, passiveValue);
}
@Override
public State calculate(List<Item> items) {
State result = super.calculate(items);
State notResult =
result.equals(activeState) ? passiveState : activeState;
State notResult = result.equals(activeState) ? passiveState : activeState;
return notResult;
}
@ -208,10 +212,10 @@ public interface ArithmeticGroupFunction extends GroupFunction {
super(activeValue, passiveValue);
}
@Override
public State calculate(List<Item> items) {
State result = super.calculate(items);
State notResult =
result.equals(activeState) ? passiveState : activeState;
State notResult = result.equals(activeState) ? passiveState : activeState;
return notResult;
}
@ -226,24 +230,26 @@ public interface ArithmeticGroupFunction extends GroupFunction {
*/
static class Avg implements GroupFunction {
public Avg() {}
public Avg() {
}
/**
* @{inheritDoc
*/
@Override
public State calculate(List<Item> items) {
BigDecimal sum = BigDecimal.ZERO;
int count = 0;
if(items!=null) {
for(Item item : items) {
if (items != null) {
for (Item item : items) {
DecimalType itemState = (DecimalType) item.getStateAs(DecimalType.class);
if(itemState!=null) {
if (itemState != null) {
sum = sum.add(itemState.toBigDecimal());
count++;
}
}
}
if(count>0) {
if (count > 0) {
return new DecimalType(sum.divide(new BigDecimal(count), RoundingMode.HALF_UP));
} else {
return UnDefType.UNDEF;
@ -253,9 +259,10 @@ public interface ArithmeticGroupFunction extends GroupFunction {
/**
* @{inheritDoc
*/
@Override
public State getStateAs(List<Item> items, Class<? extends State> stateClass) {
State state = calculate(items);
if(stateClass.isInstance(state)) {
if (stateClass.isInstance(state)) {
return state;
} else {
return null;
@ -272,17 +279,19 @@ public interface ArithmeticGroupFunction extends GroupFunction {
*/
static class Sum implements GroupFunction {
public Sum() {}
public Sum() {
}
/**
* @{inheritDoc
*/
@Override
public State calculate(List<Item> items) {
BigDecimal sum = BigDecimal.ZERO;
if(items!=null) {
for(Item item : items) {
if (items != null) {
for (Item item : items) {
DecimalType itemState = (DecimalType) item.getStateAs(DecimalType.class);
if(itemState!=null) {
if (itemState != null) {
sum = sum.add(itemState.toBigDecimal());
}
}
@ -293,9 +302,10 @@ public interface ArithmeticGroupFunction extends GroupFunction {
/**
* @{inheritDoc
*/
@Override
public State getStateAs(List<Item> items, Class<? extends State> stateClass) {
State state = calculate(items);
if(stateClass.isInstance(state)) {
if (stateClass.isInstance(state)) {
return state;
} else {
return null;
@ -312,23 +322,25 @@ public interface ArithmeticGroupFunction extends GroupFunction {
*/
static class Min implements GroupFunction {
public Min() {}
public Min() {
}
/**
* @{inheritDoc
*/
@Override
public State calculate(List<Item> items) {
if(items!=null && items.size()>0) {
if (items != null && items.size() > 0) {
BigDecimal min = null;
for(Item item : items) {
for (Item item : items) {
DecimalType itemState = (DecimalType) item.getStateAs(DecimalType.class);
if(itemState!=null) {
if(min==null || min.compareTo(itemState.toBigDecimal()) > 0) {
if (itemState != null) {
if (min == null || min.compareTo(itemState.toBigDecimal()) > 0) {
min = itemState.toBigDecimal();
}
}
}
if(min!=null) {
if (min != null) {
return new DecimalType(min);
}
}
@ -338,15 +350,16 @@ public interface ArithmeticGroupFunction extends GroupFunction {
/**
* @{inheritDoc
*/
@Override
public State getStateAs(List<Item> items, Class<? extends State> stateClass) {
State state = calculate(items);
if(stateClass.isInstance(state)) {
if (stateClass.isInstance(state)) {
return state;
} else {
return null;
}
}
}
}
/**
* This calculates the maximum value of all item states of decimal type.
@ -357,23 +370,25 @@ public interface ArithmeticGroupFunction extends GroupFunction {
*/
static class Max implements GroupFunction {
public Max() {}
public Max() {
}
/**
* @{inheritDoc
*/
@Override
public State calculate(List<Item> items) {
if(items!=null && items.size()>0) {
if (items != null && items.size() > 0) {
BigDecimal max = null;
for(Item item : items) {
for (Item item : items) {
DecimalType itemState = (DecimalType) item.getStateAs(DecimalType.class);
if(itemState!=null) {
if(max==null || max.compareTo(itemState.toBigDecimal()) < 0) {
if (itemState != null) {
if (max == null || max.compareTo(itemState.toBigDecimal()) < 0) {
max = itemState.toBigDecimal();
}
}
}
if(max!=null) {
if (max != null) {
return new DecimalType(max);
}
}
@ -383,9 +398,10 @@ public interface ArithmeticGroupFunction extends GroupFunction {
/**
* @{inheritDoc
*/
@Override
public State getStateAs(List<Item> items, Class<? extends State> stateClass) {
State state = calculate(items);
if(stateClass.isInstance(state)) {
if (stateClass.isInstance(state)) {
return state;
} else {
return null;
@ -393,5 +409,4 @@ public interface ArithmeticGroupFunction extends GroupFunction {
}
}
}

View File

@ -18,7 +18,6 @@ import org.openhab.core.types.Command;
import org.openhab.core.types.PrimitiveType;
import org.openhab.core.types.State;
public class DateTimeType implements PrimitiveType, State, Command {
public static final String DATE_PATTERN = "yyyy-MM-dd'T'HH:mm:ss";
@ -26,7 +25,6 @@ public class DateTimeType implements PrimitiveType, State, Command {
protected Calendar calendar;
public DateTimeType() {
this(Calendar.getInstance());
}
@ -41,12 +39,10 @@ public class DateTimeType implements PrimitiveType, State, Command {
try {
try {
date = new SimpleDateFormat(DATE_PATTERN_WITH_TZ).parse(calendarValue);
}
catch (ParseException fpe2) {
} catch (ParseException fpe2) {
date = new SimpleDateFormat(DATE_PATTERN).parse(calendarValue);
}
}
catch (ParseException fpe) {
} catch (ParseException fpe) {
throw new IllegalArgumentException(calendarValue + " is not in a valid format.", fpe);
}
@ -60,11 +56,11 @@ public class DateTimeType implements PrimitiveType, State, Command {
return calendar;
}
public static DateTimeType valueOf(String value) {
return new DateTimeType(value);
}
@Override
public String format(String pattern) {
try {
return String.format(pattern, calendar);
@ -92,18 +88,23 @@ public class DateTimeType implements PrimitiveType, State, Command {
@Override
public boolean equals(Object obj) {
if (this == obj)
if (this == obj) {
return true;
if (obj == null)
}
if (obj == null) {
return false;
if (getClass() != obj.getClass())
}
if (getClass() != obj.getClass()) {
return false;
}
DateTimeType other = (DateTimeType) obj;
if (calendar == null) {
if (other.calendar != null)
if (other.calendar != null) {
return false;
} else if (!calendar.equals(other.calendar))
}
} else if (!calendar.equals(other.calendar)) {
return false;
}
return true;
}

View File

@ -49,6 +49,7 @@ public class DecimalType extends Number implements PrimitiveType, State, Command
this.value = new BigDecimal(value);
}
@Override
public String toString() {
return value.toPlainString();
}
@ -57,6 +58,7 @@ public class DecimalType extends Number implements PrimitiveType, State, Command
return new DecimalType(value);
}
@Override
public String format(String pattern) {
if (pattern.contains("%d")) {
return String.format(pattern, value.toBigInteger());
@ -79,21 +81,27 @@ public class DecimalType extends Number implements PrimitiveType, State, Command
@Override
public boolean equals(Object obj) {
if (this == obj)
if (this == obj) {
return true;
if (obj == null)
}
if (obj == null) {
return false;
if (!(obj instanceof DecimalType))
}
if (!(obj instanceof DecimalType)) {
return false;
}
DecimalType other = (DecimalType) obj;
if (value == null) {
if (other.value != null)
if (other.value != null) {
return false;
} else if (value.compareTo(other.value) != 0)
}
} else if (value.compareTo(other.value) != 0) {
return false;
}
return true;
}
@Override
public int compareTo(DecimalType o) {
return value.compareTo(o.toBigDecimal());
}

View File

@ -50,14 +50,12 @@ public class HSBType extends PercentType implements ComplexType, State, Command
public HSBType(Color color) {
if (color != null) {
float[] hsbValues = Color.RGBtoHSB(color.getRed(),
color.getGreen(), color.getBlue(), null);
float[] hsbValues = Color.RGBtoHSB(color.getRed(), color.getGreen(), color.getBlue(), null);
this.hue = BigDecimal.valueOf(hsbValues[0] * 360);
this.saturation = BigDecimal.valueOf(hsbValues[1] * 100);
this.value = BigDecimal.valueOf(hsbValues[2] * 100);
} else {
throw new IllegalArgumentException(
"Constructor argument must not be null");
throw new IllegalArgumentException("Constructor argument must not be null");
}
}
@ -75,12 +73,10 @@ public class HSBType extends PercentType implements ComplexType, State, Command
this.saturation = new BigDecimal(constituents[1]);
this.value = new BigDecimal(constituents[2]);
} else {
throw new IllegalArgumentException(value
+ " is not a valid HSBType syntax");
throw new IllegalArgumentException(value + " is not a valid HSBType syntax");
}
} else {
throw new IllegalArgumentException(
"Constructor argument must not be null");
throw new IllegalArgumentException("Constructor argument must not be null");
}
}
@ -90,7 +86,7 @@ public class HSBType extends PercentType implements ComplexType, State, Command
@Override
public SortedMap<String, PrimitiveType> getConstituents() {
TreeMap<String, PrimitiveType> map = new TreeMap<String, PrimitiveType>();
TreeMap<String, PrimitiveType> map = new TreeMap<>();
map.put(KEY_HUE, getHue());
map.put(KEY_SATURATION, getSaturation());
map.put(KEY_BRIGHTNESS, getBrightness());
@ -122,17 +118,16 @@ public class HSBType extends PercentType implements ComplexType, State, Command
}
private PercentType byteToPercentType(int byteValue) {
BigDecimal percentValue = new BigDecimal(byteValue).multiply(
BigDecimal.valueOf(100)).divide(BigDecimal.valueOf(255), 2,
BigDecimal.ROUND_HALF_UP);
BigDecimal percentValue = new BigDecimal(byteValue).multiply(BigDecimal.valueOf(100))
.divide(BigDecimal.valueOf(255), 2, BigDecimal.ROUND_HALF_UP);
return new PercentType(percentValue);
}
public Color toColor() {
return Color.getHSBColor(hue.floatValue() / 360,
saturation.floatValue() / 100, value.floatValue() / 100);
return Color.getHSBColor(hue.floatValue() / 360, saturation.floatValue() / 100, value.floatValue() / 100);
}
@Override
public String toString() {
return getHue() + "," + getSaturation() + "," + getBrightness();
}
@ -147,23 +142,24 @@ public class HSBType extends PercentType implements ComplexType, State, Command
@Override
public boolean equals(Object obj) {
if (this == obj)
if (this == obj) {
return true;
if (obj == null)
}
if (obj == null) {
return false;
if (!(obj instanceof HSBType))
}
if (!(obj instanceof HSBType)) {
return false;
}
HSBType other = (HSBType) obj;
if ((getHue() != null && other.getHue() == null)
|| (getHue() == null && other.getHue() != null)
if ((getHue() != null && other.getHue() == null) || (getHue() == null && other.getHue() != null)
|| (getSaturation() != null && other.getSaturation() == null)
|| (getSaturation() == null && other.getSaturation() != null)
|| (getBrightness() != null && other.getBrightness() == null)
|| (getBrightness() == null && other.getBrightness() != null)) {
return false;
}
if (!getHue().equals(other.getHue())
|| !getSaturation().equals(other.getSaturation())
if (!getHue().equals(other.getHue()) || !getSaturation().equals(other.getSaturation())
|| !getBrightness().equals(other.getBrightness())) {
return false;
}

View File

@ -12,8 +12,10 @@ import org.openhab.core.types.Command;
import org.openhab.core.types.PrimitiveType;
public enum IncreaseDecreaseType implements PrimitiveType, Command {
INCREASE, DECREASE;
INCREASE,
DECREASE;
@Override
public String format(String pattern) {
return String.format(pattern, this.toString());
}

View File

@ -9,12 +9,14 @@
package org.openhab.core.library.types;
import org.openhab.core.types.Command;
import org.openhab.core.types.State;
import org.openhab.core.types.PrimitiveType;
import org.openhab.core.types.State;
public enum OnOffType implements PrimitiveType, State, Command {
ON, OFF;
ON,
OFF;
@Override
public String format(String pattern) {
return String.format(pattern, this.toString());
}

View File

@ -9,12 +9,14 @@
package org.openhab.core.library.types;
import org.openhab.core.types.Command;
import org.openhab.core.types.State;
import org.openhab.core.types.PrimitiveType;
import org.openhab.core.types.State;
public enum OpenClosedType implements PrimitiveType, State, Command {
OPEN, CLOSED;
OPEN,
CLOSED;
@Override
public String format(String pattern) {
return String.format(pattern, this.toString());
}

View File

@ -44,7 +44,7 @@ public class PercentType extends DecimalType {
}
private void validateValue(BigDecimal value) {
if(BigDecimal.ZERO.compareTo(value) > 0 || new BigDecimal(100).compareTo(value) < 0) {
if (BigDecimal.ZERO.compareTo(value) > 0 || new BigDecimal(100).compareTo(value) < 0) {
throw new IllegalArgumentException("Value must be between 0 and 100");
}
}

View File

@ -166,7 +166,7 @@ public class PointType implements ComplexType, Command, State {
@Override
public SortedMap<String, PrimitiveType> getConstituents() {
SortedMap<String, PrimitiveType> result = new TreeMap<String, PrimitiveType>();
SortedMap<String, PrimitiveType> result = new TreeMap<>();
result.put(KEY_LATITUDE, getLatitude());
result.put(KEY_LONGITUDE, getLongitude());
result.put(KEY_ALTITUDE, getAltitude());

View File

@ -12,8 +12,10 @@ import org.openhab.core.types.Command;
import org.openhab.core.types.PrimitiveType;
public enum StopMoveType implements PrimitiveType, Command {
STOP, MOVE;
STOP,
MOVE;
@Override
public String format(String pattern) {
return String.format(pattern, this.toString());
}

View File

@ -9,8 +9,8 @@
package org.openhab.core.library.types;
import org.openhab.core.types.Command;
import org.openhab.core.types.State;
import org.openhab.core.types.PrimitiveType;
import org.openhab.core.types.State;
public class StringType implements PrimitiveType, State, Command {
@ -22,6 +22,7 @@ public class StringType implements PrimitiveType, State, Command {
this.value = value;
}
@Override
public String toString() {
return value;
}
@ -30,6 +31,7 @@ public class StringType implements PrimitiveType, State, Command {
return new StringType(value);
}
@Override
public String format(String pattern) {
return String.format(pattern, value);
}
@ -41,15 +43,18 @@ public class StringType implements PrimitiveType, State, Command {
@Override
public boolean equals(Object obj) {
if (this == obj)
if (this == obj) {
return true;
if (obj == null)
}
if (obj == null) {
return false;
if(obj instanceof String) {
}
if (obj instanceof String) {
return obj.equals(value);
}
if (getClass() != obj.getClass())
if (getClass() != obj.getClass()) {
return false;
}
StringType other = (StringType) obj;
if (!value.equals(other.value)) {
return false;
@ -57,5 +62,4 @@ public class StringType implements PrimitiveType, State, Command {
return true;
}
}

View File

@ -9,12 +9,14 @@
package org.openhab.core.library.types;
import org.openhab.core.types.Command;
import org.openhab.core.types.State;
import org.openhab.core.types.PrimitiveType;
import org.openhab.core.types.State;
public enum UpDownType implements PrimitiveType, State, Command {
UP, DOWN;
UP,
DOWN;
@Override
public String format(String pattern) {
return String.format(pattern, this.toString());
}

View File

@ -15,14 +15,19 @@ import org.openhab.core.types.State;
/**
* This class is used to define a filter for queries to a {@link PersistenceService}.
*
* <p>It is designed as a Java bean, for which the different properties are constraints
* <p>
* It is designed as a Java bean, for which the different properties are constraints
* on the query result. These properties include the item name, begin and end date and
* the item state. A compare operator can be defined to compare not only state equality,
* but also its decimal value (<,>).<p>
* <p>Additionally, the filter criteria supports ordering and paging of the result, so the
* but also its decimal value (<,>).
* <p>
* <p>
* Additionally, the filter criteria supports ordering and paging of the result, so the
* caller can ask to only return chunks of the result of a certain size (=pageSize) from a
* starting index (pageNumber*pageSize).</p>
* <p>All setter methods return the filter criteria instance, so that the methods can be
* starting index (pageNumber*pageSize).
* </p>
* <p>
* All setter methods return the filter criteria instance, so that the methods can be
* easily chained in order to define a filter.
*
* @author Kai Kreuzer
@ -52,7 +57,8 @@ public class FilterCriteria {
/** Enumeration with all ordering options */
public enum Ordering {
ASCENDING, DESCENDING
ASCENDING,
DESCENDING
}
/** filter result to only contain entries for the given item */

View File

@ -16,9 +16,11 @@ import org.openhab.core.types.State;
* This interface is used by persistence services to represent an item
* with a certain state at a given point in time.
*
* <p>Note that this interface does not extend {@link Item} as the persistence
* <p>
* Note that this interface does not extend {@link Item} as the persistence
* services could not provide an implementation that correctly implement
* getAcceptedXTypes() and getGroupNames().</p>
* getAcceptedXTypes() and getGroupNames().
* </p>
*
* @author Kai Kreuzer
* @since 1.0.0

View File

@ -31,23 +31,29 @@ public interface PersistenceService {
/**
* Stores the current value of the given item.
* <p>Implementors should keep in mind that all registered
* <p>
* Implementors should keep in mind that all registered
* {@link PersistenceService}s are called synchronously. Hence long running
* operations should be processed asynchronously. E.g. <code>store</code>
* adds things to a queue which is processed by some asynchronous workers
* (Quartz Job, Thread, etc.).</p>
* (Quartz Job, Thread, etc.).
* </p>
*
* @param item the item which state should be persisted.
*/
void store(Item item);
/**
* <p>Stores the current value of the given item under a specified alias.</p>
* <p>Implementors should keep in mind that all registered
* <p>
* Stores the current value of the given item under a specified alias.
* </p>
* <p>
* Implementors should keep in mind that all registered
* {@link PersistenceService}s are called synchronously. Hence long running
* operations should be processed asynchronously. E.g. <code>store</code>
* adds things to a queue which is processed by some asynchronous workers
* (Quartz Job, Thread, etc.).</p>
* (Quartz Job, Thread, etc.).
* </p>
*
* @param item the item which state should be persisted.
* @param alias the alias under which the item should be persisted.

View File

@ -34,13 +34,14 @@ public class PersistenceServiceFactory {
public void activate(BundleContext context) {
this.context = context;
for(PersistenceService service : persistenceServices) {
for (PersistenceService service : persistenceServices) {
registerDelegateService(service);
}
}
public void deactivate() {
for(ServiceRegistration<org.eclipse.smarthome.core.persistence.PersistenceService> serviceReg : delegates.values()) {
for (ServiceRegistration<org.eclipse.smarthome.core.persistence.PersistenceService> serviceReg : delegates
.values()) {
serviceReg.unregister();
}
delegates.clear();
@ -48,7 +49,7 @@ public class PersistenceServiceFactory {
}
public void addPersistenceService(PersistenceService service) {
if(context!=null) {
if (context != null) {
registerDelegateService(service);
} else {
persistenceServices.add(service);
@ -56,28 +57,27 @@ public class PersistenceServiceFactory {
}
public void removePersistenceService(PersistenceService service) {
if(context!=null) {
if (context != null) {
unregisterDelegateService(service);
}
}
private void registerDelegateService(PersistenceService persistenceService) {
if(!delegates.containsKey(persistenceService.getName())) {
org.eclipse.smarthome.core.persistence.PersistenceService service =
(persistenceService instanceof org.openhab.core.persistence.QueryablePersistenceService) ?
new QueryablePersistenceServiceDelegate(persistenceService)
if (!delegates.containsKey(persistenceService.getName())) {
org.eclipse.smarthome.core.persistence.PersistenceService service = (persistenceService instanceof org.openhab.core.persistence.QueryablePersistenceService)
? new QueryablePersistenceServiceDelegate(persistenceService)
: new PersistenceServiceDelegate(persistenceService);
Dictionary<String, Object> props = new Hashtable<String, Object>();
ServiceRegistration<org.eclipse.smarthome.core.persistence.PersistenceService> serviceReg =
context.registerService(org.eclipse.smarthome.core.persistence.PersistenceService.class, service, props);
Dictionary<String, Object> props = new Hashtable<>();
ServiceRegistration<org.eclipse.smarthome.core.persistence.PersistenceService> serviceReg = context
.registerService(org.eclipse.smarthome.core.persistence.PersistenceService.class, service, props);
delegates.put(persistenceService.getName(), serviceReg);
}
}
private void unregisterDelegateService(PersistenceService service) {
if(delegates.containsKey(service.getName())) {
ServiceRegistration<org.eclipse.smarthome.core.persistence.PersistenceService> serviceReg =
delegates.get(service.getName());
if (delegates.containsKey(service.getName())) {
ServiceRegistration<org.eclipse.smarthome.core.persistence.PersistenceService> serviceReg = delegates
.get(service.getName());
delegates.remove(service.getName());
serviceReg.unregister();
}

View File

@ -19,5 +19,6 @@ import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
public @interface ActionDoc {
String text();
String returns() default "";
}

View File

@ -19,5 +19,6 @@ import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
public @interface ParamDoc {
String name();
String text() default "";
}

View File

@ -65,7 +65,7 @@ public class ActionServiceFactory {
private void registerDelegateService(ActionService actionService) {
if (!delegates.containsKey(actionService.getActionClassName())) {
ActionServiceDelegate service = new ActionServiceDelegate(actionService);
Dictionary<String, Object> props = new Hashtable<String, Object>();
Dictionary<String, Object> props = new Hashtable<>();
ServiceRegistration<org.eclipse.smarthome.model.script.engine.action.ActionService> serviceReg = context
.registerService(org.eclipse.smarthome.model.script.engine.action.ActionService.class, service,
props);

View File

@ -11,7 +11,6 @@ package org.openhab.core.service;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Base class for services that frequently run some action in a separate thread in the
* background.
@ -38,12 +37,10 @@ public abstract class AbstractActiveService {
*/
private Thread refreshThread;
public AbstractActiveService() {
super();
}
public void activate() {
start();
}
@ -107,7 +104,6 @@ public abstract class AbstractActiveService {
return properlyConfigured;
}
/**
* Used to define whether this binding is fully configured so that it can be
* activated and used.
@ -171,7 +167,7 @@ public abstract class AbstractActiveService {
while (!shutdown) {
try {
execute();
} catch(RuntimeException e) {
} catch (RuntimeException e) {
logger.error("Error while executing background thread " + getName(), e);
}
pause(refreshInterval);
@ -191,9 +187,8 @@ public abstract class AbstractActiveService {
try {
Thread.sleep(refreshInterval);
}
catch (InterruptedException e) {
logger.debug("pausing thread " + super.getName() +" interrupted");
} catch (InterruptedException e) {
logger.debug("pausing thread " + super.getName() + " interrupted");
}
}

View File

@ -8,7 +8,6 @@
*/
package org.openhab.core.transform;
/**
* A TransformationException is thrown when any step of a transformation went
* wrong. The originating exception should be attached to increase traceability.

View File

@ -28,16 +28,16 @@ public class TransformationHelper {
* @return a service instance or null, if none could be found
*/
static public TransformationService getTransformationService(BundleContext context, String transformationType) {
if(context!=null) {
if (context != null) {
String filter = "(smarthome.transform=" + transformationType + ")";
try {
Collection<ServiceReference<org.eclipse.smarthome.core.transform.TransformationService>> refs =
context.getServiceReferences(org.eclipse.smarthome.core.transform.TransformationService.class, filter);
if(refs!=null && refs.size() > 0) {
return new TransformationServiceDelegate(
(org.eclipse.smarthome.core.transform.TransformationService) context.getService(refs.iterator().next()));
Collection<ServiceReference<org.eclipse.smarthome.core.transform.TransformationService>> refs = context
.getServiceReferences(org.eclipse.smarthome.core.transform.TransformationService.class, filter);
if (refs != null && refs.size() > 0) {
return new TransformationServiceDelegate(context.getService(refs.iterator().next()));
} else {
logger.warn("Cannot get service reference for transformation service of type " + transformationType);
logger.warn(
"Cannot get service reference for transformation service of type " + transformationType);
}
} catch (InvalidSyntaxException e) {
logger.warn("Cannot get service reference for transformation service of type " + transformationType, e);
@ -55,8 +55,7 @@ public class TransformationHelper {
}
@Override
public String transform(String function, String source)
throws TransformationException {
public String transform(String function, String source) throws TransformationException {
try {
return delegate.transform(function, source);
} catch (org.eclipse.smarthome.core.transform.TransformationException e) {

View File

@ -8,7 +8,6 @@
*/
package org.openhab.core.transform;
/**
* A TransformationProcessor transforms a given input and returns the transformed
* result. Transformations could make sense in various situations, for example:

View File

@ -39,8 +39,9 @@ public class Transformation {
*/
public static String transform(String type, String function, String value) {
String result;
TransformationService service = TransformationHelper.getTransformationService(CompatibilityActivator.getContext(), type);
if(service!=null) {
TransformationService service = TransformationHelper
.getTransformationService(CompatibilityActivator.getContext(), type);
if (service != null) {
try {
result = service.transform(function, value);
} catch (TransformationException e) {

View File

@ -20,12 +20,16 @@ package org.openhab.core.types;
*
*/
public enum EventType {
COMMAND, UPDATE;
COMMAND,
UPDATE;
@Override
public String toString() {
switch(this) {
case COMMAND: return "command";
case UPDATE: return "update";
switch (this) {
case COMMAND:
return "command";
case UPDATE:
return "update";
}
return "";
}

View File

@ -8,7 +8,6 @@
*/
package org.openhab.core.types;
/**
* A primitive type consists of a single value like a string, a number, etc.
*

View File

@ -26,6 +26,7 @@ public interface Type {
/**
* Formats the value of this type according to a pattern (see {@link Formatter}).
*
* @param pattern the pattern to use
* @return the formatted string
*/

View File

@ -22,23 +22,29 @@ import java.util.List;
public class TypeParser {
/**
* <p>Determines a state from a string. Possible state types are passed as a parameter.
* <p>
* Determines a state from a string. Possible state types are passed as a parameter.
* Note that the order matters here; the first type that accepts the string as a valid
* value, will be used for the state.</p>
* <p>Example: The type list is OnOffType.class,StringType.class. The string "ON" is now
* value, will be used for the state.
* </p>
* <p>
* Example: The type list is OnOffType.class,StringType.class. The string "ON" is now
* accepted by the OnOffType and thus OnOffType.ON will be returned (and not a StringType
* with value "ON").</p>
* with value "ON").
* </p>
*
* @param types possible types of the state to consider
* @param s the string to parse
* @return the corresponding State instance or <code>null</code>
*/
public static State parseState(List<Class<? extends State>> types, String s) {
for(Class<? extends Type> type : types) {
for (Class<? extends Type> type : types) {
try {
Method valueOf = type.getMethod("valueOf", String.class);
State state = (State) valueOf.invoke(type, s);
if(state!=null) return state;
if (state != null) {
return state;
}
} catch (NoSuchMethodException e) {
} catch (IllegalArgumentException e) {
} catch (IllegalAccessException e) {
@ -49,24 +55,30 @@ public class TypeParser {
}
/**
* <p>Determines a command from a string. Possible command types are passed as a parameter.
* <p>
* Determines a command from a string. Possible command types are passed as a parameter.
* Note that the order matters here; the first type that accepts the string as a valid
* value, will be used for the command.</p>
* <p>Example: The type list is OnOffType.class,StringType.class. The string "ON" is now
* value, will be used for the command.
* </p>
* <p>
* Example: The type list is OnOffType.class,StringType.class. The string "ON" is now
* accepted by the OnOffType and thus OnOffType.ON will be returned (and not a StringType
* with value "ON").</p>
* with value "ON").
* </p>
*
* @param types possible types of the command to consider
* @param s the string to parse
* @return the corresponding Command instance or <code>null</code>
*/
public static Command parseCommand(List<Class<? extends Command>> types, String s) {
if(s!=null) {
for(Class<? extends Command> type : types) {
if (s != null) {
for (Class<? extends Command> type : types) {
try {
Method valueOf = type.getMethod("valueOf", String.class);
Command value = (Command) valueOf.invoke(type, s);
if(value!=null) return value;
if (value != null) {
return value;
}
} catch (NoSuchMethodException e) {
} catch (IllegalArgumentException e) {
} catch (IllegalAccessException e) {

View File

@ -20,16 +20,21 @@ package org.openhab.core.types;
*
*/
public enum UnDefType implements PrimitiveType, State {
UNDEF, NULL;
UNDEF,
NULL;
@Override
public String toString() {
switch(this) {
case UNDEF: return "Undefined";
case NULL: return "Uninitialized";
switch (this) {
case UNDEF:
return "Undefined";
case NULL:
return "Uninitialized";
}
return "";
}
@Override
public String format(String pattern) {
return String.format(pattern, this.toString());
}

View File

@ -23,7 +23,8 @@ public interface Console {
public void println(String s);
/** usage output is treated differently from other output as it might
/**
* usage output is treated differently from other output as it might
* differ between different kinds of consoles
*
* @param s the main usage string (console independent)

View File

@ -42,8 +42,8 @@ public class Exec {
* the command line to execute
* @see http://www.peterfriese.de/running-applescript-from-java/
*/
@ActionDoc(text="Executes <code>commandLine</code>.")
static public void executeCommandLine(@ParamDoc(name="commandLine") String commandLine) {
@ActionDoc(text = "Executes <code>commandLine</code>.")
static public void executeCommandLine(@ParamDoc(name = "commandLine") String commandLine) {
ExecUtil.executeCommandLine(commandLine);
}
@ -67,10 +67,9 @@ public class Exec {
* timeout for execution in milliseconds
* @return response data from executed command line
*/
@ActionDoc(text="Executes <code>commandLine</code>.")
static public String executeCommandLine(
@ParamDoc(name="commandLine")String commandLine,
@ParamDoc(name="timeout", text="timeout for execution in milliseconds") int timeout) {
@ActionDoc(text = "Executes <code>commandLine</code>.")
static public String executeCommandLine(@ParamDoc(name = "commandLine") String commandLine,
@ParamDoc(name = "timeout", text = "timeout for execution in milliseconds") int timeout) {
return ExecUtil.executeCommandLineAndWaitResponse(commandLine, timeout);
}

View File

@ -24,7 +24,6 @@ public class HTTP {
/** Constant which represents the content type <code>application/json</code> */
public final static String CONTENT_TYPE_JSON = "application/json";
/**
* Send out a GET-HTTP request. Errors will be logged, returned values just ignored.
*

View File

@ -15,7 +15,6 @@ import java.net.Socket;
import java.net.SocketAddress;
import java.net.SocketTimeoutException;
/**
* This Action checks the vitality of the given host.
*
@ -47,8 +46,7 @@ public class Ping {
if (host != null && timeout > 0) {
if (port == 0) {
success = InetAddress.getByName(host).isReachable(timeout);
}
else {
} else {
SocketAddress socketAddress = new InetSocketAddress(host, port);
try (Socket socket = new Socket()) {
@ -62,5 +60,4 @@ public class Ping {
return success;
}
}

View File

@ -38,7 +38,6 @@ import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Some common methods to be used in both HTTP-In-Binding and HTTP-Out-Binding
*
@ -53,7 +52,6 @@ public class HttpUtil {
/** {@link Pattern} which matches the credentials out of an URL */
private static final Pattern URL_CREDENTIALS_PATTERN = Pattern.compile("http://(.*?):(.*?)@.*");
/**
* Executes the given <code>url</code> with the given <code>httpMethod</code>.
* Furthermore the <code>http.proxyXXX</code> System variables are read and
@ -83,7 +81,8 @@ public class HttpUtil {
*
* @return the response body or <code>NULL</code> when the request went wrong
*/
public static String executeUrl(String httpMethod, String url, InputStream content, String contentType, int timeout) {
public static String executeUrl(String httpMethod, String url, InputStream content, String contentType,
int timeout) {
return executeUrl(httpMethod, url, null, content, contentType, timeout);
}
@ -103,7 +102,8 @@ public class HttpUtil {
*
* @return the response body or <code>NULL</code> when the request went wrong
*/
public static String executeUrl(String httpMethod, String url, Properties httpHeaders, InputStream content, String contentType, int timeout) {
public static String executeUrl(String httpMethod, String url, Properties httpHeaders, InputStream content,
String contentType, int timeout) {
String proxySet = System.getProperty("http.proxySet");
String proxyHost = null;
@ -118,7 +118,7 @@ public class HttpUtil {
if (StringUtils.isNotBlank(proxyPortString)) {
try {
proxyPort = Integer.valueOf(proxyPortString);
} catch(NumberFormatException e) {
} catch (NumberFormatException e) {
logger.warn("'{}' is not a valid proxy port - using port 80 instead");
}
}
@ -127,7 +127,8 @@ public class HttpUtil {
nonProxyHosts = System.getProperty("http.nonProxyHosts");
}
return executeUrl(httpMethod, url, httpHeaders, content, contentType, timeout, proxyHost, proxyPort, proxyUser, proxyPassword, nonProxyHosts);
return executeUrl(httpMethod, url, httpHeaders, content, contentType, timeout, proxyHost, proxyPort, proxyUser,
proxyPassword, nonProxyHosts);
}
@ -148,7 +149,9 @@ public class HttpUtil {
* @param nonProxyHosts the hosts that won't be routed through the proxy
* @return the response body or <code>NULL</code> when the request went wrong
*/
public static String executeUrl(String httpMethod, String url, Properties httpHeaders, InputStream content, String contentType, int timeout, String proxyHost, Integer proxyPort, String proxyUser, String proxyPassword, String nonProxyHosts) {
public static String executeUrl(String httpMethod, String url, Properties httpHeaders, InputStream content,
String contentType, int timeout, String proxyHost, Integer proxyPort, String proxyUser,
String proxyPassword, String nonProxyHosts) {
HttpClient client = new HttpClient();
@ -163,15 +166,14 @@ public class HttpUtil {
HttpMethod method = HttpUtil.createHttpMethod(httpMethod, url);
method.getParams().setSoTimeout(timeout);
method.getParams().setParameter(HttpMethodParams.RETRY_HANDLER,
new DefaultHttpMethodRetryHandler(3, false));
if(httpHeaders != null){
for(String httpHeaderKey: httpHeaders.stringPropertyNames()){
method.addRequestHeader(new Header(httpHeaderKey,httpHeaders.getProperty(httpHeaderKey)));
method.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, new DefaultHttpMethodRetryHandler(3, false));
if (httpHeaders != null) {
for (String httpHeaderKey : httpHeaders.stringPropertyNames()) {
method.addRequestHeader(new Header(httpHeaderKey, httpHeaders.getProperty(httpHeaderKey)));
}
}
// add content if a valid method is given ...
if (method instanceof EntityEnclosingMethod && content != null ) {
if (method instanceof EntityEnclosingMethod && content != null) {
EntityEnclosingMethod eeMethod = (EntityEnclosingMethod) method;
eeMethod.setRequestEntity(new InputStreamRequestEntity(content, contentType));
}
@ -203,14 +205,11 @@ public class HttpUtil {
}
return responseBody;
}
catch (HttpException he) {
} catch (HttpException he) {
logger.error("Fatal protocol violation: {}", he.toString());
}
catch (IOException ioe) {
} catch (IOException ioe) {
logger.error("Fatal transport error: {}", ioe.toString());
}
finally {
} finally {
method.releaseConnection();
}
@ -264,6 +263,7 @@ public class HttpUtil {
/**
* Extracts username and password from the given <code>url</code>. A valid
* url to extract {@link Credentials} from looks like:
*
* <pre>
* http://username:password@www.domain.org
* </pre>
@ -289,8 +289,7 @@ public class HttpUtil {
password = matcher.group(2);
}
Credentials credentials =
new UsernamePasswordCredentials(username, password);
Credentials credentials = new UsernamePasswordCredentials(username, password);
return credentials;
}
@ -301,10 +300,10 @@ public class HttpUtil {
* Factory method to create a {@link HttpMethod}-object according to the
* given String <code>httpMethod</codde>
*
* @param httpMethodString the name of the {@link HttpMethod} to create
* @param url
* &#64;param httpMethodString the name of the {@link HttpMethod} to create
* &#64;param url
*
* @return an object of type {@link GetMethod}, {@link PutMethod},
* &#64;return an object of type {@link GetMethod}, {@link PutMethod},
* {@link PostMethod} or {@link DeleteMethod}
* @throws IllegalArgumentException if <code>httpMethod</code> is none of
* <code>GET</code>, <code>PUT</code>, <code>POST</POST> or <code>DELETE</code>
@ -313,17 +312,13 @@ public class HttpUtil {
if ("GET".equals(httpMethodString)) {
return new GetMethod(url);
}
else if ("PUT".equals(httpMethodString)) {
} else if ("PUT".equals(httpMethodString)) {
return new PutMethod(url);
}
else if ("POST".equals(httpMethodString)) {
} else if ("POST".equals(httpMethodString)) {
return new PostMethod(url);
}
else if ("DELETE".equals(httpMethodString)) {
} else if ("DELETE".equals(httpMethodString)) {
return new DeleteMethod(url);
}
else {
} else {
throw new IllegalArgumentException("given httpMethod '" + httpMethodString + "' is unknown");
}
}

View File

@ -16,7 +16,6 @@ import javax.servlet.http.HttpServletResponse;
import org.osgi.service.http.HttpContext;
/**
* Implementation of {@link HttpContext} which adds Basic-Authentication
* functionality to openHAB.
@ -35,19 +34,28 @@ public class SecureHttpContext implements HttpContext {
this.defaultContext = defaultContext;
}
/**
* <p>@{inheritDoc}</p>
* <p>Delegates to <code>defaultContext.getMimeType()</code>
* <p>
*
* @{inheritDoc}
* </p>
* <p>
* Delegates to <code>defaultContext.getMimeType()</code>
*/
@Override
public String getMimeType(String name) {
return this.defaultContext.getMimeType(name);
}
/**
* <p>@{inheritDoc}</p>
* <p>Delegates to <code>defaultContext.getResource()</code>
* <p>
*
* @{inheritDoc}
* </p>
* <p>
* Delegates to <code>defaultContext.getResource()</code>
*/
@Override
public URL getResource(String name) {
return this.defaultContext.getResource(name);
}

View File

@ -19,8 +19,8 @@ import org.openhab.library.tel.types.CallType;
public class CallItem extends GenericItem {
private static List<Class<? extends State>> acceptedDataTypes = new ArrayList<Class<? extends State>>();
private static List<Class<? extends Command>> acceptedCommandTypes = new ArrayList<Class<? extends Command>>();
private static List<Class<? extends State>> acceptedDataTypes = new ArrayList<>();
private static List<Class<? extends Command>> acceptedCommandTypes = new ArrayList<>();
static {
acceptedDataTypes.add(CallType.class);
@ -31,10 +31,12 @@ public class CallItem extends GenericItem {
super(name);
}
@Override
public List<Class<? extends State>> getAcceptedDataTypes() {
return acceptedDataTypes;
}
@Override
public List<Class<? extends Command>> getAcceptedCommandTypes() {
return acceptedCommandTypes;
}

View File

@ -30,7 +30,7 @@ public class CallType implements ComplexType, Command, State {
public static final State EMPTY = new CallType(new StringType(""), new StringType(""));
public CallType() {
callDetails = new TreeMap<String, PrimitiveType>();
callDetails = new TreeMap<>();
}
public CallType(String value) {

View File

@ -42,16 +42,16 @@ public abstract class AbstractGenericBindingProvider implements BindingConfigRea
private static final Logger logger = LoggerFactory.getLogger(AbstractGenericBindingProvider.class);
private Set<BindingChangeListener> listeners = new CopyOnWriteArraySet<BindingChangeListener>();
private Set<BindingChangeListener> listeners = new CopyOnWriteArraySet<>();
/** caches binding configurations. maps itemNames to {@link BindingConfig}s */
protected Map<String, BindingConfig> bindingConfigs = new ConcurrentHashMap<String, BindingConfig>();
protected Map<String, BindingConfig> bindingConfigs = new ConcurrentHashMap<>();
/**
* stores information about the context of items. The map has this content
* structure: context -> Set of Items
*/
protected Map<String, Set<Item>> contextMap = new ConcurrentHashMap<String, Set<Item>>();
protected Map<String, Set<Item>> contextMap = new ConcurrentHashMap<>();
public AbstractGenericBindingProvider() {
super();
@ -85,7 +85,7 @@ public abstract class AbstractGenericBindingProvider implements BindingConfigRea
synchronized (contextMap) {
Set<Item> items = contextMap.get(context);
if (items == null) {
items = new HashSet<Item>();
items = new HashSet<>();
contextMap.put(context, items);
}
items.add(item);
@ -149,7 +149,7 @@ public abstract class AbstractGenericBindingProvider implements BindingConfigRea
*/
@Override
public Collection<String> getItemNames() {
return new ArrayList<String>(bindingConfigs.keySet());
return new ArrayList<>(bindingConfigs.keySet());
}
}

View File

@ -49,7 +49,8 @@ public interface BindingConfigReader {
*
* @throws BindingConfigParseException if the configuration string is not valid
*/
public void processBindingConfiguration(String context, Item item, String bindingConfig) throws BindingConfigParseException;
public void processBindingConfiguration(String context, Item item, String bindingConfig)
throws BindingConfigParseException;
/**
* Removes all configuration information for a given context. This is usually called if a config file is reloaded,

View File

@ -10,7 +10,6 @@
*/
package org.openhab.model.sitemap;
/**
* <!-- begin-user-doc -->
* A representation of the model object '<em><b>Chart</b></em>'.
@ -29,8 +28,7 @@ package org.openhab.model.sitemap;
* @model
* @generated
*/
public interface Chart extends NonLinkableWidget
{
public interface Chart extends NonLinkableWidget {
/**
* Returns the value of the '<em><b>Service</b></em>' attribute.
* <!-- begin-user-doc -->
@ -39,6 +37,7 @@ public interface Chart extends NonLinkableWidget
* there really should be more of a description here...
* </p>
* <!-- end-user-doc -->
*
* @return the value of the '<em>Service</em>' attribute.
* @see #setService(String)
* @see org.openhab.model.sitemap.SitemapPackage#getChart_Service()
@ -51,6 +50,7 @@ public interface Chart extends NonLinkableWidget
* Sets the value of the '{@link org.openhab.model.sitemap.Chart#getService <em>Service</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @param value the new value of the '<em>Service</em>' attribute.
* @see #getService()
* @generated
@ -65,6 +65,7 @@ public interface Chart extends NonLinkableWidget
* there really should be more of a description here...
* </p>
* <!-- end-user-doc -->
*
* @return the value of the '<em>Refresh</em>' attribute.
* @see #setRefresh(int)
* @see org.openhab.model.sitemap.SitemapPackage#getChart_Refresh()
@ -77,6 +78,7 @@ public interface Chart extends NonLinkableWidget
* Sets the value of the '{@link org.openhab.model.sitemap.Chart#getRefresh <em>Refresh</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @param value the new value of the '<em>Refresh</em>' attribute.
* @see #getRefresh()
* @generated
@ -91,6 +93,7 @@ public interface Chart extends NonLinkableWidget
* there really should be more of a description here...
* </p>
* <!-- end-user-doc -->
*
* @return the value of the '<em>Period</em>' attribute.
* @see #setPeriod(String)
* @see org.openhab.model.sitemap.SitemapPackage#getChart_Period()
@ -103,6 +106,7 @@ public interface Chart extends NonLinkableWidget
* Sets the value of the '{@link org.openhab.model.sitemap.Chart#getPeriod <em>Period</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @param value the new value of the '<em>Period</em>' attribute.
* @see #getPeriod()
* @generated

View File

@ -32,8 +32,7 @@ import org.eclipse.emf.ecore.EObject;
* @model
* @generated
*/
public interface ColorArray extends EObject
{
public interface ColorArray extends EObject {
/**
* Returns the value of the '<em><b>Item</b></em>' attribute.
* <!-- begin-user-doc -->
@ -42,6 +41,7 @@ public interface ColorArray extends EObject
* there really should be more of a description here...
* </p>
* <!-- end-user-doc -->
*
* @return the value of the '<em>Item</em>' attribute.
* @see #setItem(String)
* @see org.openhab.model.sitemap.SitemapPackage#getColorArray_Item()
@ -54,6 +54,7 @@ public interface ColorArray extends EObject
* Sets the value of the '{@link org.openhab.model.sitemap.ColorArray#getItem <em>Item</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @param value the new value of the '<em>Item</em>' attribute.
* @see #getItem()
* @generated
@ -68,6 +69,7 @@ public interface ColorArray extends EObject
* there really should be more of a description here...
* </p>
* <!-- end-user-doc -->
*
* @return the value of the '<em>Condition</em>' attribute.
* @see #setCondition(String)
* @see org.openhab.model.sitemap.SitemapPackage#getColorArray_Condition()
@ -80,6 +82,7 @@ public interface ColorArray extends EObject
* Sets the value of the '{@link org.openhab.model.sitemap.ColorArray#getCondition <em>Condition</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @param value the new value of the '<em>Condition</em>' attribute.
* @see #getCondition()
* @generated
@ -94,6 +97,7 @@ public interface ColorArray extends EObject
* there really should be more of a description here...
* </p>
* <!-- end-user-doc -->
*
* @return the value of the '<em>Sign</em>' attribute.
* @see #setSign(String)
* @see org.openhab.model.sitemap.SitemapPackage#getColorArray_Sign()
@ -106,6 +110,7 @@ public interface ColorArray extends EObject
* Sets the value of the '{@link org.openhab.model.sitemap.ColorArray#getSign <em>Sign</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @param value the new value of the '<em>Sign</em>' attribute.
* @see #getSign()
* @generated
@ -120,6 +125,7 @@ public interface ColorArray extends EObject
* there really should be more of a description here...
* </p>
* <!-- end-user-doc -->
*
* @return the value of the '<em>State</em>' attribute.
* @see #setState(String)
* @see org.openhab.model.sitemap.SitemapPackage#getColorArray_State()
@ -132,6 +138,7 @@ public interface ColorArray extends EObject
* Sets the value of the '{@link org.openhab.model.sitemap.ColorArray#getState <em>State</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @param value the new value of the '<em>State</em>' attribute.
* @see #getState()
* @generated
@ -146,6 +153,7 @@ public interface ColorArray extends EObject
* there really should be more of a description here...
* </p>
* <!-- end-user-doc -->
*
* @return the value of the '<em>Arg</em>' attribute.
* @see #setArg(String)
* @see org.openhab.model.sitemap.SitemapPackage#getColorArray_Arg()
@ -158,6 +166,7 @@ public interface ColorArray extends EObject
* Sets the value of the '{@link org.openhab.model.sitemap.ColorArray#getArg <em>Arg</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @param value the new value of the '<em>Arg</em>' attribute.
* @see #getArg()
* @generated

View File

@ -10,7 +10,6 @@
*/
package org.openhab.model.sitemap;
/**
* <!-- begin-user-doc -->
* A representation of the model object '<em><b>Colorpicker</b></em>'.
@ -27,8 +26,7 @@ package org.openhab.model.sitemap;
* @model
* @generated
*/
public interface Colorpicker extends NonLinkableWidget
{
public interface Colorpicker extends NonLinkableWidget {
/**
* Returns the value of the '<em><b>Frequency</b></em>' attribute.
* <!-- begin-user-doc -->
@ -37,6 +35,7 @@ public interface Colorpicker extends NonLinkableWidget
* there really should be more of a description here...
* </p>
* <!-- end-user-doc -->
*
* @return the value of the '<em>Frequency</em>' attribute.
* @see #setFrequency(int)
* @see org.openhab.model.sitemap.SitemapPackage#getColorpicker_Frequency()
@ -49,6 +48,7 @@ public interface Colorpicker extends NonLinkableWidget
* Sets the value of the '{@link org.openhab.model.sitemap.Colorpicker#getFrequency <em>Frequency</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @param value the new value of the '<em>Frequency</em>' attribute.
* @see #getFrequency()
* @generated

View File

@ -10,7 +10,6 @@
*/
package org.openhab.model.sitemap;
/**
* <!-- begin-user-doc -->
* A representation of the model object '<em><b>Frame</b></em>'.
@ -21,6 +20,5 @@ package org.openhab.model.sitemap;
* @model
* @generated
*/
public interface Frame extends LinkableWidget
{
public interface Frame extends LinkableWidget {
} // Frame

View File

@ -10,7 +10,6 @@
*/
package org.openhab.model.sitemap;
/**
* <!-- begin-user-doc -->
* A representation of the model object '<em><b>Group</b></em>'.
@ -21,6 +20,5 @@ package org.openhab.model.sitemap;
* @model
* @generated
*/
public interface Group extends LinkableWidget
{
public interface Group extends LinkableWidget {
} // Group

View File

@ -30,8 +30,7 @@ import org.eclipse.emf.common.util.EList;
* @model
* @generated
*/
public interface Image extends LinkableWidget
{
public interface Image extends LinkableWidget {
/**
* Returns the value of the '<em><b>Url</b></em>' attribute.
* <!-- begin-user-doc -->
@ -40,6 +39,7 @@ public interface Image extends LinkableWidget
* there really should be more of a description here...
* </p>
* <!-- end-user-doc -->
*
* @return the value of the '<em>Url</em>' attribute.
* @see #setUrl(String)
* @see org.openhab.model.sitemap.SitemapPackage#getImage_Url()
@ -52,6 +52,7 @@ public interface Image extends LinkableWidget
* Sets the value of the '{@link org.openhab.model.sitemap.Image#getUrl <em>Url</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @param value the new value of the '<em>Url</em>' attribute.
* @see #getUrl()
* @generated
@ -66,6 +67,7 @@ public interface Image extends LinkableWidget
* there really should be more of a description here...
* </p>
* <!-- end-user-doc -->
*
* @return the value of the '<em>Refresh</em>' attribute.
* @see #setRefresh(int)
* @see org.openhab.model.sitemap.SitemapPackage#getImage_Refresh()
@ -78,6 +80,7 @@ public interface Image extends LinkableWidget
* Sets the value of the '{@link org.openhab.model.sitemap.Image#getRefresh <em>Refresh</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @param value the new value of the '<em>Refresh</em>' attribute.
* @see #getRefresh()
* @generated
@ -93,6 +96,7 @@ public interface Image extends LinkableWidget
* there really should be more of a description here...
* </p>
* <!-- end-user-doc -->
*
* @return the value of the '<em>Icon Color</em>' containment reference list.
* @see org.openhab.model.sitemap.SitemapPackage#getImage_IconColor()
* @model containment="true"

View File

@ -28,8 +28,7 @@ import org.eclipse.emf.common.util.EList;
* @model
* @generated
*/
public interface LinkableWidget extends Widget
{
public interface LinkableWidget extends Widget {
/**
* Returns the value of the '<em><b>Children</b></em>' containment reference list.
* The list contents are of type {@link org.openhab.model.sitemap.Widget}.
@ -39,6 +38,7 @@ public interface LinkableWidget extends Widget
* there really should be more of a description here...
* </p>
* <!-- end-user-doc -->
*
* @return the value of the '<em>Children</em>' containment reference list.
* @see org.openhab.model.sitemap.SitemapPackage#getLinkableWidget_Children()
* @model containment="true"

View File

@ -10,7 +10,6 @@
*/
package org.openhab.model.sitemap;
/**
* <!-- begin-user-doc -->
* A representation of the model object '<em><b>List</b></em>'.
@ -27,8 +26,7 @@ package org.openhab.model.sitemap;
* @model
* @generated
*/
public interface List extends NonLinkableWidget
{
public interface List extends NonLinkableWidget {
/**
* Returns the value of the '<em><b>Separator</b></em>' attribute.
* <!-- begin-user-doc -->
@ -37,6 +35,7 @@ public interface List extends NonLinkableWidget
* there really should be more of a description here...
* </p>
* <!-- end-user-doc -->
*
* @return the value of the '<em>Separator</em>' attribute.
* @see #setSeparator(String)
* @see org.openhab.model.sitemap.SitemapPackage#getList_Separator()
@ -49,6 +48,7 @@ public interface List extends NonLinkableWidget
* Sets the value of the '{@link org.openhab.model.sitemap.List#getSeparator <em>Separator</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @param value the new value of the '<em>Separator</em>' attribute.
* @see #getSeparator()
* @generated

View File

@ -29,8 +29,7 @@ import org.eclipse.emf.ecore.EObject;
* @model
* @generated
*/
public interface Mapping extends EObject
{
public interface Mapping extends EObject {
/**
* Returns the value of the '<em><b>Cmd</b></em>' attribute.
* <!-- begin-user-doc -->
@ -39,6 +38,7 @@ public interface Mapping extends EObject
* there really should be more of a description here...
* </p>
* <!-- end-user-doc -->
*
* @return the value of the '<em>Cmd</em>' attribute.
* @see #setCmd(String)
* @see org.openhab.model.sitemap.SitemapPackage#getMapping_Cmd()
@ -51,6 +51,7 @@ public interface Mapping extends EObject
* Sets the value of the '{@link org.openhab.model.sitemap.Mapping#getCmd <em>Cmd</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @param value the new value of the '<em>Cmd</em>' attribute.
* @see #getCmd()
* @generated
@ -65,6 +66,7 @@ public interface Mapping extends EObject
* there really should be more of a description here...
* </p>
* <!-- end-user-doc -->
*
* @return the value of the '<em>Label</em>' attribute.
* @see #setLabel(String)
* @see org.openhab.model.sitemap.SitemapPackage#getMapping_Label()
@ -77,6 +79,7 @@ public interface Mapping extends EObject
* Sets the value of the '{@link org.openhab.model.sitemap.Mapping#getLabel <em>Label</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @param value the new value of the '<em>Label</em>' attribute.
* @see #getLabel()
* @generated

View File

@ -10,7 +10,6 @@
*/
package org.openhab.model.sitemap;
/**
* <!-- begin-user-doc -->
* A representation of the model object '<em><b>Non Linkable Widget</b></em>'.
@ -21,6 +20,5 @@ package org.openhab.model.sitemap;
* @model
* @generated
*/
public interface NonLinkableWidget extends Widget
{
public interface NonLinkableWidget extends Widget {
} // NonLinkableWidget

View File

@ -28,8 +28,7 @@ import org.eclipse.emf.common.util.EList;
* @model
* @generated
*/
public interface Selection extends NonLinkableWidget
{
public interface Selection extends NonLinkableWidget {
/**
* Returns the value of the '<em><b>Mappings</b></em>' containment reference list.
* The list contents are of type {@link org.openhab.model.sitemap.Mapping}.
@ -39,6 +38,7 @@ public interface Selection extends NonLinkableWidget
* there really should be more of a description here...
* </p>
* <!-- end-user-doc -->
*
* @return the value of the '<em>Mappings</em>' containment reference list.
* @see org.openhab.model.sitemap.SitemapPackage#getSelection_Mappings()
* @model containment="true"

View File

@ -30,8 +30,7 @@ import java.math.BigDecimal;
* @model
* @generated
*/
public interface Setpoint extends NonLinkableWidget
{
public interface Setpoint extends NonLinkableWidget {
/**
* Returns the value of the '<em><b>Min Value</b></em>' attribute.
* <!-- begin-user-doc -->
@ -40,6 +39,7 @@ public interface Setpoint extends NonLinkableWidget
* there really should be more of a description here...
* </p>
* <!-- end-user-doc -->
*
* @return the value of the '<em>Min Value</em>' attribute.
* @see #setMinValue(BigDecimal)
* @see org.openhab.model.sitemap.SitemapPackage#getSetpoint_MinValue()
@ -52,6 +52,7 @@ public interface Setpoint extends NonLinkableWidget
* Sets the value of the '{@link org.openhab.model.sitemap.Setpoint#getMinValue <em>Min Value</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @param value the new value of the '<em>Min Value</em>' attribute.
* @see #getMinValue()
* @generated
@ -66,6 +67,7 @@ public interface Setpoint extends NonLinkableWidget
* there really should be more of a description here...
* </p>
* <!-- end-user-doc -->
*
* @return the value of the '<em>Max Value</em>' attribute.
* @see #setMaxValue(BigDecimal)
* @see org.openhab.model.sitemap.SitemapPackage#getSetpoint_MaxValue()
@ -78,6 +80,7 @@ public interface Setpoint extends NonLinkableWidget
* Sets the value of the '{@link org.openhab.model.sitemap.Setpoint#getMaxValue <em>Max Value</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @param value the new value of the '<em>Max Value</em>' attribute.
* @see #getMaxValue()
* @generated
@ -92,6 +95,7 @@ public interface Setpoint extends NonLinkableWidget
* there really should be more of a description here...
* </p>
* <!-- end-user-doc -->
*
* @return the value of the '<em>Step</em>' attribute.
* @see #setStep(BigDecimal)
* @see org.openhab.model.sitemap.SitemapPackage#getSetpoint_Step()
@ -104,6 +108,7 @@ public interface Setpoint extends NonLinkableWidget
* Sets the value of the '{@link org.openhab.model.sitemap.Setpoint#getStep <em>Step</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @param value the new value of the '<em>Step</em>' attribute.
* @see #getStep()
* @generated

View File

@ -31,8 +31,7 @@ import org.eclipse.emf.common.util.EList;
* @model
* @generated
*/
public interface Sitemap extends SitemapModel
{
public interface Sitemap extends SitemapModel {
/**
* Returns the value of the '<em><b>Name</b></em>' attribute.
* <!-- begin-user-doc -->
@ -41,6 +40,7 @@ public interface Sitemap extends SitemapModel
* there really should be more of a description here...
* </p>
* <!-- end-user-doc -->
*
* @return the value of the '<em>Name</em>' attribute.
* @see #setName(String)
* @see org.openhab.model.sitemap.SitemapPackage#getSitemap_Name()
@ -53,6 +53,7 @@ public interface Sitemap extends SitemapModel
* Sets the value of the '{@link org.openhab.model.sitemap.Sitemap#getName <em>Name</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @param value the new value of the '<em>Name</em>' attribute.
* @see #getName()
* @generated
@ -67,6 +68,7 @@ public interface Sitemap extends SitemapModel
* there really should be more of a description here...
* </p>
* <!-- end-user-doc -->
*
* @return the value of the '<em>Label</em>' attribute.
* @see #setLabel(String)
* @see org.openhab.model.sitemap.SitemapPackage#getSitemap_Label()
@ -79,6 +81,7 @@ public interface Sitemap extends SitemapModel
* Sets the value of the '{@link org.openhab.model.sitemap.Sitemap#getLabel <em>Label</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @param value the new value of the '<em>Label</em>' attribute.
* @see #getLabel()
* @generated
@ -93,6 +96,7 @@ public interface Sitemap extends SitemapModel
* there really should be more of a description here...
* </p>
* <!-- end-user-doc -->
*
* @return the value of the '<em>Icon</em>' attribute.
* @see #setIcon(String)
* @see org.openhab.model.sitemap.SitemapPackage#getSitemap_Icon()
@ -105,6 +109,7 @@ public interface Sitemap extends SitemapModel
* Sets the value of the '{@link org.openhab.model.sitemap.Sitemap#getIcon <em>Icon</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @param value the new value of the '<em>Icon</em>' attribute.
* @see #getIcon()
* @generated
@ -120,6 +125,7 @@ public interface Sitemap extends SitemapModel
* there really should be more of a description here...
* </p>
* <!-- end-user-doc -->
*
* @return the value of the '<em>Children</em>' containment reference list.
* @see org.openhab.model.sitemap.SitemapPackage#getSitemap_Children()
* @model containment="true"

View File

@ -22,6 +22,5 @@ import org.eclipse.emf.ecore.EObject;
* @model
* @generated
*/
public interface SitemapModel extends EObject
{
public interface SitemapModel extends EObject {
} // SitemapModel

View File

@ -10,7 +10,6 @@
*/
package org.openhab.model.sitemap;
/**
* <!-- begin-user-doc -->
* A representation of the model object '<em><b>Slider</b></em>'.
@ -28,8 +27,7 @@ package org.openhab.model.sitemap;
* @model
* @generated
*/
public interface Slider extends NonLinkableWidget
{
public interface Slider extends NonLinkableWidget {
/**
* Returns the value of the '<em><b>Frequency</b></em>' attribute.
* <!-- begin-user-doc -->
@ -38,6 +36,7 @@ public interface Slider extends NonLinkableWidget
* there really should be more of a description here...
* </p>
* <!-- end-user-doc -->
*
* @return the value of the '<em>Frequency</em>' attribute.
* @see #setFrequency(int)
* @see org.openhab.model.sitemap.SitemapPackage#getSlider_Frequency()
@ -50,6 +49,7 @@ public interface Slider extends NonLinkableWidget
* Sets the value of the '{@link org.openhab.model.sitemap.Slider#getFrequency <em>Frequency</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @param value the new value of the '<em>Frequency</em>' attribute.
* @see #getFrequency()
* @generated
@ -64,6 +64,7 @@ public interface Slider extends NonLinkableWidget
* there really should be more of a description here...
* </p>
* <!-- end-user-doc -->
*
* @return the value of the '<em>Switch Enabled</em>' attribute.
* @see #setSwitchEnabled(boolean)
* @see org.openhab.model.sitemap.SitemapPackage#getSlider_SwitchEnabled()
@ -73,9 +74,11 @@ public interface Slider extends NonLinkableWidget
boolean isSwitchEnabled();
/**
* Sets the value of the '{@link org.openhab.model.sitemap.Slider#isSwitchEnabled <em>Switch Enabled</em>}' attribute.
* Sets the value of the '{@link org.openhab.model.sitemap.Slider#isSwitchEnabled <em>Switch Enabled</em>}'
* attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @param value the new value of the '<em>Switch Enabled</em>' attribute.
* @see #isSwitchEnabled()
* @generated

View File

@ -28,8 +28,7 @@ import org.eclipse.emf.common.util.EList;
* @model
* @generated
*/
public interface Switch extends NonLinkableWidget
{
public interface Switch extends NonLinkableWidget {
/**
* Returns the value of the '<em><b>Mappings</b></em>' containment reference list.
* The list contents are of type {@link org.openhab.model.sitemap.Mapping}.
@ -39,6 +38,7 @@ public interface Switch extends NonLinkableWidget
* there really should be more of a description here...
* </p>
* <!-- end-user-doc -->
*
* @return the value of the '<em>Mappings</em>' containment reference list.
* @see org.openhab.model.sitemap.SitemapPackage#getSwitch_Mappings()
* @model containment="true"

View File

@ -10,7 +10,6 @@
*/
package org.openhab.model.sitemap;
/**
* <!-- begin-user-doc -->
* A representation of the model object '<em><b>Text</b></em>'.
@ -21,6 +20,5 @@ package org.openhab.model.sitemap;
* @model
* @generated
*/
public interface Text extends LinkableWidget
{
public interface Text extends LinkableWidget {
} // Text

View File

@ -10,7 +10,6 @@
*/
package org.openhab.model.sitemap;
/**
* <!-- begin-user-doc -->
* A representation of the model object '<em><b>Video</b></em>'.
@ -27,8 +26,7 @@ package org.openhab.model.sitemap;
* @model
* @generated
*/
public interface Video extends NonLinkableWidget
{
public interface Video extends NonLinkableWidget {
/**
* Returns the value of the '<em><b>Url</b></em>' attribute.
* <!-- begin-user-doc -->
@ -37,6 +35,7 @@ public interface Video extends NonLinkableWidget
* there really should be more of a description here...
* </p>
* <!-- end-user-doc -->
*
* @return the value of the '<em>Url</em>' attribute.
* @see #setUrl(String)
* @see org.openhab.model.sitemap.SitemapPackage#getVideo_Url()
@ -49,6 +48,7 @@ public interface Video extends NonLinkableWidget
* Sets the value of the '{@link org.openhab.model.sitemap.Video#getUrl <em>Url</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @param value the new value of the '<em>Url</em>' attribute.
* @see #getUrl()
* @generated

View File

@ -31,8 +31,7 @@ import org.eclipse.emf.ecore.EObject;
* @model
* @generated
*/
public interface VisibilityRule extends EObject
{
public interface VisibilityRule extends EObject {
/**
* Returns the value of the '<em><b>Item</b></em>' attribute.
* <!-- begin-user-doc -->
@ -41,6 +40,7 @@ public interface VisibilityRule extends EObject
* there really should be more of a description here...
* </p>
* <!-- end-user-doc -->
*
* @return the value of the '<em>Item</em>' attribute.
* @see #setItem(String)
* @see org.openhab.model.sitemap.SitemapPackage#getVisibilityRule_Item()
@ -53,6 +53,7 @@ public interface VisibilityRule extends EObject
* Sets the value of the '{@link org.openhab.model.sitemap.VisibilityRule#getItem <em>Item</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @param value the new value of the '<em>Item</em>' attribute.
* @see #getItem()
* @generated
@ -67,6 +68,7 @@ public interface VisibilityRule extends EObject
* there really should be more of a description here...
* </p>
* <!-- end-user-doc -->
*
* @return the value of the '<em>Condition</em>' attribute.
* @see #setCondition(String)
* @see org.openhab.model.sitemap.SitemapPackage#getVisibilityRule_Condition()
@ -76,9 +78,11 @@ public interface VisibilityRule extends EObject
String getCondition();
/**
* Sets the value of the '{@link org.openhab.model.sitemap.VisibilityRule#getCondition <em>Condition</em>}' attribute.
* Sets the value of the '{@link org.openhab.model.sitemap.VisibilityRule#getCondition <em>Condition</em>}'
* attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @param value the new value of the '<em>Condition</em>' attribute.
* @see #getCondition()
* @generated
@ -93,6 +97,7 @@ public interface VisibilityRule extends EObject
* there really should be more of a description here...
* </p>
* <!-- end-user-doc -->
*
* @return the value of the '<em>Sign</em>' attribute.
* @see #setSign(String)
* @see org.openhab.model.sitemap.SitemapPackage#getVisibilityRule_Sign()
@ -105,6 +110,7 @@ public interface VisibilityRule extends EObject
* Sets the value of the '{@link org.openhab.model.sitemap.VisibilityRule#getSign <em>Sign</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @param value the new value of the '<em>Sign</em>' attribute.
* @see #getSign()
* @generated
@ -119,6 +125,7 @@ public interface VisibilityRule extends EObject
* there really should be more of a description here...
* </p>
* <!-- end-user-doc -->
*
* @return the value of the '<em>State</em>' attribute.
* @see #setState(String)
* @see org.openhab.model.sitemap.SitemapPackage#getVisibilityRule_State()
@ -131,6 +138,7 @@ public interface VisibilityRule extends EObject
* Sets the value of the '{@link org.openhab.model.sitemap.VisibilityRule#getState <em>State</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @param value the new value of the '<em>State</em>' attribute.
* @see #getState()
* @generated

View File

@ -10,7 +10,6 @@
*/
package org.openhab.model.sitemap;
/**
* <!-- begin-user-doc -->
* A representation of the model object '<em><b>Webview</b></em>'.
@ -28,8 +27,7 @@ package org.openhab.model.sitemap;
* @model
* @generated
*/
public interface Webview extends NonLinkableWidget
{
public interface Webview extends NonLinkableWidget {
/**
* Returns the value of the '<em><b>Height</b></em>' attribute.
* <!-- begin-user-doc -->
@ -38,6 +36,7 @@ public interface Webview extends NonLinkableWidget
* there really should be more of a description here...
* </p>
* <!-- end-user-doc -->
*
* @return the value of the '<em>Height</em>' attribute.
* @see #setHeight(int)
* @see org.openhab.model.sitemap.SitemapPackage#getWebview_Height()
@ -50,6 +49,7 @@ public interface Webview extends NonLinkableWidget
* Sets the value of the '{@link org.openhab.model.sitemap.Webview#getHeight <em>Height</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @param value the new value of the '<em>Height</em>' attribute.
* @see #getHeight()
* @generated
@ -64,6 +64,7 @@ public interface Webview extends NonLinkableWidget
* there really should be more of a description here...
* </p>
* <!-- end-user-doc -->
*
* @return the value of the '<em>Url</em>' attribute.
* @see #setUrl(String)
* @see org.openhab.model.sitemap.SitemapPackage#getWebview_Url()
@ -76,6 +77,7 @@ public interface Webview extends NonLinkableWidget
* Sets the value of the '{@link org.openhab.model.sitemap.Webview#getUrl <em>Url</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @param value the new value of the '<em>Url</em>' attribute.
* @see #getUrl()
* @generated

View File

@ -11,7 +11,6 @@
package org.openhab.model.sitemap;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EObject;
/**
@ -35,8 +34,7 @@ import org.eclipse.emf.ecore.EObject;
* @model
* @generated
*/
public interface Widget extends EObject
{
public interface Widget extends EObject {
/**
* Returns the value of the '<em><b>Item</b></em>' attribute.
* <!-- begin-user-doc -->
@ -45,6 +43,7 @@ public interface Widget extends EObject
* there really should be more of a description here...
* </p>
* <!-- end-user-doc -->
*
* @return the value of the '<em>Item</em>' attribute.
* @see #setItem(String)
* @see org.openhab.model.sitemap.SitemapPackage#getWidget_Item()
@ -57,6 +56,7 @@ public interface Widget extends EObject
* Sets the value of the '{@link org.openhab.model.sitemap.Widget#getItem <em>Item</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @param value the new value of the '<em>Item</em>' attribute.
* @see #getItem()
* @generated
@ -71,6 +71,7 @@ public interface Widget extends EObject
* there really should be more of a description here...
* </p>
* <!-- end-user-doc -->
*
* @return the value of the '<em>Label</em>' attribute.
* @see #setLabel(String)
* @see org.openhab.model.sitemap.SitemapPackage#getWidget_Label()
@ -83,6 +84,7 @@ public interface Widget extends EObject
* Sets the value of the '{@link org.openhab.model.sitemap.Widget#getLabel <em>Label</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @param value the new value of the '<em>Label</em>' attribute.
* @see #getLabel()
* @generated
@ -97,6 +99,7 @@ public interface Widget extends EObject
* there really should be more of a description here...
* </p>
* <!-- end-user-doc -->
*
* @return the value of the '<em>Icon</em>' attribute.
* @see #setIcon(String)
* @see org.openhab.model.sitemap.SitemapPackage#getWidget_Icon()
@ -109,6 +112,7 @@ public interface Widget extends EObject
* Sets the value of the '{@link org.openhab.model.sitemap.Widget#getIcon <em>Icon</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @param value the new value of the '<em>Icon</em>' attribute.
* @see #getIcon()
* @generated
@ -124,6 +128,7 @@ public interface Widget extends EObject
* there really should be more of a description here...
* </p>
* <!-- end-user-doc -->
*
* @return the value of the '<em>Label Color</em>' containment reference list.
* @see org.openhab.model.sitemap.SitemapPackage#getWidget_LabelColor()
* @model containment="true"
@ -140,6 +145,7 @@ public interface Widget extends EObject
* there really should be more of a description here...
* </p>
* <!-- end-user-doc -->
*
* @return the value of the '<em>Value Color</em>' containment reference list.
* @see org.openhab.model.sitemap.SitemapPackage#getWidget_ValueColor()
* @model containment="true"
@ -156,6 +162,7 @@ public interface Widget extends EObject
* there really should be more of a description here...
* </p>
* <!-- end-user-doc -->
*
* @return the value of the '<em>Visibility</em>' containment reference list.
* @see org.openhab.model.sitemap.SitemapPackage#getWidget_Visibility()
* @model containment="true"

View File

@ -70,8 +70,8 @@ public interface ChartProvider {
* @throws ItemNotFoundException if an item or group is not found
* @throws IllegalArgumentException if an invalid argument is passed
*/
BufferedImage createChart(String service, String theme, Date startTime, Date endTime, int height,
int width, String items, String groups) throws ItemNotFoundException;
BufferedImage createChart(String service, String theme, Date startTime, Date endTime, int height, int width,
String items, String groups) throws ItemNotFoundException;
/**
* Gets the type of data that will be written by the chart.
@ -85,6 +85,8 @@ public interface ChartProvider {
*
*/
public enum ImageType {
png, jpg, gif;
png,
jpg,
gif;
}
}

View File

@ -15,7 +15,6 @@ import org.apache.commons.lang.StringUtils;
import org.eclipse.smarthome.core.items.ItemNotFoundException;
import org.openhab.ui.chart.ChartProvider;
/**
* This class serves as a mapping from the "old" org.openhab namespace to the new org.eclipse.smarthome
* namespace for the action service. It wraps an instance with the old interface

View File

@ -34,13 +34,13 @@ public class ChartProviderFactory {
public void activate(BundleContext context) {
this.context = context;
for(ChartProvider provider : chartProviders) {
for (ChartProvider provider : chartProviders) {
registerDelegateProvider(provider);
}
}
public void deactivate() {
for(ServiceRegistration<org.eclipse.smarthome.ui.chart.ChartProvider> serviceReg : delegates.values()) {
for (ServiceRegistration<org.eclipse.smarthome.ui.chart.ChartProvider> serviceReg : delegates.values()) {
serviceReg.unregister();
}
delegates.clear();
@ -48,7 +48,7 @@ public class ChartProviderFactory {
}
public void addChartProvider(ChartProvider provider) {
if(context!=null) {
if (context != null) {
registerDelegateProvider(provider);
} else {
chartProviders.add(provider);
@ -56,25 +56,25 @@ public class ChartProviderFactory {
}
public void removeChartProvider(ChartProvider provider) {
if(context!=null) {
if (context != null) {
unregisterDelegateProvider(provider);
}
}
private void registerDelegateProvider(ChartProvider chartProvider) {
if(!delegates.containsKey(chartProvider.getName())) {
if (!delegates.containsKey(chartProvider.getName())) {
ChartProviderDelegate service = new ChartProviderDelegate(chartProvider);
Dictionary<String, Object> props = new Hashtable<String, Object>();
ServiceRegistration<org.eclipse.smarthome.ui.chart.ChartProvider> serviceReg =
context.registerService(org.eclipse.smarthome.ui.chart.ChartProvider.class, service, props);
Dictionary<String, Object> props = new Hashtable<>();
ServiceRegistration<org.eclipse.smarthome.ui.chart.ChartProvider> serviceReg = context
.registerService(org.eclipse.smarthome.ui.chart.ChartProvider.class, service, props);
delegates.put(chartProvider.getName(), serviceReg);
}
}
private void unregisterDelegateProvider(ChartProvider chartProvider) {
if(delegates.containsKey(chartProvider.getName())) {
ServiceRegistration<org.eclipse.smarthome.ui.chart.ChartProvider> serviceReg =
delegates.get(chartProvider.getName());
if (delegates.containsKey(chartProvider.getName())) {
ServiceRegistration<org.eclipse.smarthome.ui.chart.ChartProvider> serviceReg = delegates
.get(chartProvider.getName());
delegates.remove(chartProvider.getName());
serviceReg.unregister();
}

View File

@ -11,7 +11,6 @@ package org.openhab.ui.items;
import org.openhab.core.items.Item;
import org.openhab.model.sitemap.Widget;
/**
* This interface describes the methods that need to be implemented by a provider that
* wants to define the appearance of an item in the UI.
@ -54,12 +53,16 @@ public interface ItemUIProvider {
public Widget getDefaultWidget(Class<? extends Item> itemType, String itemName);
/**
* <p>Provides a widget for a given item. This can be used to overwrite the widget
* <p>
* Provides a widget for a given item. This can be used to overwrite the widget
* listed in the sitemap. A use case for this is that the sitemap defines merely
* the parent-child-relation of widgets, but the concrete widget to be used for
* rendering might be selected dynamically at runtime.</p>
* <p>If the sitemap widget should not be overridden, this method must return
* <code>null</code>.</p>
* rendering might be selected dynamically at runtime.
* </p>
* <p>
* If the sitemap widget should not be overridden, this method must return
* <code>null</code>.
* </p>
*
* @param itemName the item name to get the widget for
* @return a widget to use for the given item or <code>null</code> if sitemap should not be overridden.

View File

@ -8,8 +8,7 @@
*/
package org.openhab.core.karaf.internal.command;
import static org.apache.karaf.shell.support.ansi.SimpleAnsi.INTENSITY_BOLD;
import static org.apache.karaf.shell.support.ansi.SimpleAnsi.INTENSITY_NORMAL;
import static org.apache.karaf.shell.support.ansi.SimpleAnsi.*;
import java.io.File;
import java.io.FileInputStream;
@ -58,8 +57,8 @@ public class InstallServiceCommand implements Action {
private static final String SERVICE_START_TYPE = "AUTO_START";
private static final String[] ARG_EXCLUSION_LIST = new String[] { "-Djava.endorsed", "-Djava.ext", "-Dkaraf.home", "-Dkaraf.base", "-Dkaraf.data",
"-Dkaraf.etc", "-Dkaraf.start", "-agentlib" };
private static final String[] ARG_EXCLUSION_LIST = new String[] { "-Djava.endorsed", "-Djava.ext", "-Dkaraf.home",
"-Dkaraf.base", "-Dkaraf.data", "-Dkaraf.etc", "-Dkaraf.start", "-agentlib" };
@Reference
private WrapperService service;
@ -74,7 +73,7 @@ public class InstallServiceCommand implements Action {
// get current JVM arguments
RuntimeMXBean runtimeMxBean = ManagementFactory.getRuntimeMXBean();
List<String> jvmArguments = runtimeMxBean.getInputArguments();
List<String> argumentsToAdd = new ArrayList<String>();
List<String> argumentsToAdd = new ArrayList<>();
// filter out standard karaf and debug arguments
for (String arg : jvmArguments) {
@ -119,7 +118,7 @@ public class InstallServiceCommand implements Action {
String os = System.getProperty("os.name", "Unknown");
// read contents of config file.
List<String> content = new ArrayList<String>();
List<String> content = new ArrayList<>();
InputStream is = null;
try {
is = new FileInputStream(wrapperConf);
@ -340,7 +339,8 @@ public class InstallServiceCommand implements Action {
System.out.println(INTENSITY_BOLD + "Mac OS X system detected:" + INTENSITY_NORMAL);
System.out.println("");
System.out.println("To configure openHAB as a " + INTENSITY_BOLD + "user service" + INTENSITY_NORMAL + " execute the following file move:");
System.out.println("To configure openHAB as a " + INTENSITY_BOLD + "user service" + INTENSITY_NORMAL
+ " execute the following file move:");
System.out.println("> mv " + serviceFile.getPath() + " ~/Library/LaunchAgents/");
System.out.println("");
System.out.println("To configure openHAB as a " + INTENSITY_BOLD + "system service" + INTENSITY_NORMAL
@ -354,7 +354,8 @@ public class InstallServiceCommand implements Action {
System.out.println("> launchctl start openHAB");
System.out.println("> launchctl stop openHAB");
System.out.println("");
System.out.println("After restart of your session or system you can use the launchctl command to start and stop your service");
System.out.println(
"After restart of your session or system you can use the launchctl command to start and stop your service");
System.out.println("");
System.out.println("For removing the service call:");
System.out.println("> launchctl remove openHAB");
@ -403,8 +404,9 @@ public class InstallServiceCommand implements Action {
* inputstream
*/
private void safeClose(InputStream is) {
if (is == null)
if (is == null) {
return;
}
try {
is.close();
} catch (Throwable t) {
@ -419,8 +421,9 @@ public class InstallServiceCommand implements Action {
* outputstream
*/
private void safeClose(OutputStream os) {
if (os == null)
if (os == null) {
return;
}
try {
os.close();
} catch (Throwable t) {

View File

@ -35,7 +35,7 @@ public class CoreActivator implements BundleActivator {
// TODO: This should probably better be moved in a new bundle, so that the core bundle does
// not have a (optional) dependency on model.rule.runtime anymore.
try {
ServiceTracker<RuleEngine, RuleEngine> tracker = new ServiceTracker<RuleEngine, RuleEngine>(context,
ServiceTracker<RuleEngine, RuleEngine> tracker = new ServiceTracker<>(context,
RuleEngine.class, null);
tracker.open();
tracker.waitForService(10000);

View File

@ -11,18 +11,18 @@
<p><em>October 9, 2015</em></p>
<h3>License</h3>
<p>openHAB makes available all content in this plug-in (&quot;Content&quot;). Unless otherwise
<p>The openHAB community makes available all content in this plug-in (&quot;Content&quot;). Unless otherwise
indicated below, the Content is provided to you under the terms and conditions of the
Eclipse Public License Version 1.0 (&quot;EPL&quot;). A copy of the EPL is available
at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
<p>If you did not receive this Content directly from openHAB, the Content is
<p>If you did not receive this Content directly from the openHAB community, the Content is
being redistributed by another party (&quot;Redistributor&quot;) and different terms and conditions may
apply to your use of any object code in the Content. Check the Redistributor's license that was
provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
indicated below, the terms and conditions of the EPL still apply to any source code in the Content
and such source code may be obtained at <a href="http://www.eclipse.org/">http://www.eclipse.org</a>.</p>
and such source code may be obtained at <a href="http://www.openhab.org/">openhab.org</a>.</p>
<h3>Third Party Content</h3>

View File

@ -20,12 +20,14 @@ public interface DashboardTile {
/**
* The name that should appear on the tile
*
* @return name of the tile
*/
String getName();
/**
* The url to point to (if it is a local UI, it should be a relative path starting with "../")
*
* @return the url
*/
String getUrl();
@ -33,6 +35,7 @@ public interface DashboardTile {
/**
* The url to point to for the dashboard tile.
* (if it is a local UI, it should be a relative path starting with "../")
*
* @return the tile url
*/
String getImageUrl();

View File

@ -51,7 +51,7 @@ public class DashboardService {
protected void activate(ComponentContext componentContext) {
try {
bundleContext = componentContext.getBundleContext();
Hashtable<String, String> props = new Hashtable<String, String>();
Hashtable<String, String> props = new Hashtable<>();
httpService.registerServlet(DASHBOARD_ALIAS + "/" + SERVLET_NAME, createServlet(), props,
httpService.createDefaultHttpContext());
httpService.registerResources(DASHBOARD_ALIAS, "web", null);