<commit_before>/**
 * Copyright (c) 2014-2015 openHAB UG (haftungsbeschraenkt) and others.
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 */
package org.openhab.core.compat1x.internal;

import org.eclipse.smarthome.core.items.GroupItem;
import org.eclipse.smarthome.core.items.Item;
import org.eclipse.smarthome.core.library.items.ColorItem;
import org.eclipse.smarthome.core.library.items.ContactItem;
import org.eclipse.smarthome.core.library.items.DateTimeItem;
import org.eclipse.smarthome.core.library.items.DimmerItem;
import org.eclipse.smarthome.core.library.items.NumberItem;
import org.eclipse.smarthome.core.library.items.RollershutterItem;
import org.eclipse.smarthome.core.library.items.StringItem;
import org.eclipse.smarthome.core.library.items.SwitchItem;
import org.eclipse.smarthome.core.types.State;
import org.eclipse.smarthome.core.types.UnDefType;
import org.openhab.core.items.GenericItem;
import org.openhab.core.types.TypeParser;
import org.openhab.library.tel.items.ESHCallItem;

public class ItemMapper {

	public static org.openhab.core.items.Item mapToOpenHABItem(Item item) {
		org.openhab.core.items.Item result = null;
		Class<? extends Item> itemClass = item.getClass();
		
		if (itemClass.equals(StringItem.class))
			result = new org.openhab.core.library.items.StringItem(item.getName());
		else if (itemClass.equals(SwitchItem.class))
			result = new org.openhab.core.library.items.SwitchItem(item.getName());
		else if (itemClass.equals(ContactItem.class))
			result = new org.openhab.core.library.items.ContactItem(item.getName());
		else if (itemClass.equals(NumberItem.class))
			result = new org.openhab.core.library.items.NumberItem(item.getName());
		else if (itemClass.equals(RollershutterItem.class))
			result = new org.openhab.core.library.items.RollershutterItem(item.getName());
		else if (itemClass.equals(DimmerItem.class))
			result = new org.openhab.core.library.items.DimmerItem(item.getName());
		else if (itemClass.equals(ColorItem.class))
			result = new org.openhab.core.library.items.ColorItem(item.getName());
		else if (itemClass.equals(DateTimeItem.class))
			result = new org.openhab.core.library.items.DateTimeItem(item.getName());
		else if (itemClass.equals(ESHCallItem.class))
			result = new org.openhab.library.tel.items.CallItem(item.getName());

		if (item instanceof GroupItem) {
			GroupItem gItem = (GroupItem) item;<commit_msg>fixed NPE related to #260<commit_after>/**
 * Copyright (c) 2014-2015 openHAB UG (haftungsbeschraenkt) and others.
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 */
package org.openhab.core.compat1x.internal;

import org.eclipse.smarthome.core.items.GroupItem;
import org.eclipse.smarthome.core.items.Item;
import org.eclipse.smarthome.core.library.items.ColorItem;
import org.eclipse.smarthome.core.library.items.ContactItem;
import org.eclipse.smarthome.core.library.items.DateTimeItem;
import org.eclipse.smarthome.core.library.items.DimmerItem;
import org.eclipse.smarthome.core.library.items.NumberItem;
import org.eclipse.smarthome.core.library.items.RollershutterItem;
import org.eclipse.smarthome.core.library.items.StringItem;
import org.eclipse.smarthome.core.library.items.SwitchItem;
import org.eclipse.smarthome.core.types.State;
import org.eclipse.smarthome.core.types.UnDefType;
import org.openhab.core.items.GenericItem;
import org.openhab.core.types.TypeParser;
import org.openhab.library.tel.items.ESHCallItem;

public class ItemMapper {

	public static org.openhab.core.items.Item mapToOpenHABItem(Item item) {
		if (item==null) {
		    return null;
		}
	    
	    org.openhab.core.items.Item result = null;
		Class<? extends Item> itemClass = item.getClass();
		
		if (itemClass.equals(StringItem.class))
			result = new org.openhab.core.library.items.StringItem(item.getName());
		else if (itemClass.equals(SwitchItem.class))
			result = new org.openhab.core.library.items.SwitchItem(item.getName());
		else if (itemClass.equals(ContactItem.class))
			result = new org.openhab.core.library.items.ContactItem(item.getName());
		else if (itemClass.equals(NumberItem.class))
			result = new org.openhab.core.library.items.NumberItem(item.getName());
		else if (itemClass.equals(RollershutterItem.class))
			result = new org.openhab.core.library.items.RollershutterItem(item.getName());
		else if (itemClass.equals(DimmerItem.class))
			result = new org.openhab.core.library.items.DimmerItem(item.getName());
		else if (itemClass.equals(ColorItem.class))
			result = new org.openhab.core.library.items.ColorItem(item.getName());
		else if (itemClass.equals(DateTimeItem.class))
			result = new org.openhab.core.library.items.DateTimeItem(item.getName());
		else if (itemClass.equals(ESHCallItem.class))
			result = new org.openhab.library.tel.items.CallItem(item.getName());

		if (item instanceof GroupItem) {
			GroupItem gItem = (GroupItem) item;
{'fraction_non_alphanumeric': 0.12438376943496397, 'fraction_numerical': 0.005498672734167614, 'mean_word_length': 5.09122401847575, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6277999', 'n_tokens_mistral': 1771, 'n_tokens_neox': 1662, 'n_words': 303}