Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 /*
  * Copyright (c) SiteWhere, LLC. All rights reserved. http://www.sitewhere.com
  *
  * The software in this package is published under the terms of the CPAL v1.0
  * license, a copy of which has been included with this distribution in the
  * LICENSE.txt file.
  */
 package com.sitewhere.device.marshaling;
 
Configurable helper class that allows com.sitewhere.rest.model.device.group.DeviceGroupElement model objects to be created from com.sitewhere.spi.device.group.IDeviceGroupElement SPI objects.

Author(s):
dadams
Static logger instance
	private static Logger LOGGER = Logger.getLogger(DeviceGroupElementMarshalHelper.class);

Indicates whether detailed device or device group information is to be included
	private boolean includeDetails = false;

Helper class for enriching device information
					true);

Convert the SPI object to a model object for marshaling.

Parameters:
source
manager
Returns:
Throws:
com.sitewhere.spi.SiteWhereException
		result.setGroupToken(source.getGroupToken());
		result.setIndex(source.getIndex());
		result.setType(source.getType());
		result.setElementId(source.getElementId());
		result.getRoles().addAll(source.getRoles());
		if (isIncludeDetails()) {
			switch (source.getType()) {
			case : {
				IDevice device =
								source.getElementId());
				if (device != null) {
					Device inflated = .convert(devicemanager);
					result.setDevice(inflated);
else {
					.warn("Group references invalid device: " + source.getElementId());
				}
				break;
			}
			case : {
				IDeviceGroup group =
				if (group != null) {
					DeviceGroup inflated = DeviceGroup.copy(group);
					result.setDeviceGroup(inflated);
else {
					.warn("Group references invalid subgroup: " + source.getElementId());
				}
				break;
			}
			}
		}
		return result;
	}
	public boolean isIncludeDetails() {
	}
	public DeviceGroupElementMarshalHelper setIncludeDetails(boolean includeDetails) {
		this. = includeDetails;
		return this;
	}
New to GrepCode? Check out our FAQ X