/**
 * Copyright (c) 2014-2017 by the respective copyright holders.
 * 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.eclipse.smarthome.binding.ntp.internal;

import static org.eclipse.smarthome.binding.ntp.NtpBindingConstants.*;

import java.util.Locale;

import org.eclipse.smarthome.binding.ntp.handler.NtpHandler;
import org.eclipse.smarthome.core.i18n.LocaleProvider;
import org.eclipse.smarthome.core.thing.Thing;
import org.eclipse.smarthome.core.thing.ThingTypeUID;
import org.eclipse.smarthome.core.thing.binding.BaseThingHandlerFactory;
import org.eclipse.smarthome.core.thing.binding.ThingHandler;

/**
 * The {@link NtpHandlerFactory} is responsible for creating things and thing
 * handlers.
 *
 * @author Marcel Verpaalen - Initial contribution
 * @author Markus Rathgeb - Add locale provider support
 */
public class NtpHandlerFactory extends BaseThingHandlerFactory {

    private class LocaleProviderHolder implements LocaleProvider {
        private LocaleProvider localeProvider;

        @Override
        public Locale getLocale() {
            return localeProvider.getLocale();
        }
    }

    private final LocaleProviderHolder localeProviderHolder = new LocaleProviderHolder();

    protected void setLocaleProvider(final LocaleProvider localeProvider) {
        localeProviderHolder.localeProvider = localeProvider;
    }

    protected void unsetLocaleProvider(final LocaleProvider localeProvider) {
        localeProviderHolder.localeProvider = null;
    }

    @Override
    public boolean supportsThingType(ThingTypeUID thingTypeUID) {
        return SUPPORTED_THING_TYPES_UIDS.contains(thingTypeUID);
    }

    @Override
    protected ThingHandler createHandler(Thing thing) {

        ThingTypeUID thingTypeUID = thing.getThingTypeUID();

        if (thingTypeUID.equals(THING_TYPE_NTP)) {
            return new NtpHandler(thing, localeProviderHolder);
        }

        return null;
    }
}

@@ -451,36 +451,8 @@
 %0D%0A%0D%0A
-import java.util.Locale;%0D%0A%0D%0A
 impo
@@ -505,24 +505,24 @@
 tpHandler;%0D%0A
+
 import org.e
@@ -1107,326 +1107,37 @@
 ate 
-class LocaleProviderHolder implements LocaleProvider %7B%0D%0A        private LocaleProvider localeProvider;%0D%0A%0D%0A        @Override%0D%0A        public Locale getLocale() %7B%0D%0A            return localeProvider.getLocale();%0D%0A        %7D%0D%0A    %7D%0D%0A%0D%0A    private final LocaleProviderHolder localeProviderHolder = new LocaleProviderHolder()
+LocaleProvider localeProvider
 ;%0D%0A%0D
@@ -1222,36 +1222,20 @@
         
-localeProviderHolder
+this
 .localeP
@@ -1357,36 +1357,20 @@
         
-localeProviderHolder
+this
 .localeP
@@ -1739,24 +1739,24 @@
 PE_NTP)) %7B%0D%0A
+
             
@@ -1802,14 +1802,8 @@
 ider
-Holder
 );%0D%0A

Remove unnecessary localeProviderHolder from NTP Binding (#3717)