2 * Copyright (c) 2010-2023 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
7 * This program and the accompanying materials are made available under the
8 * terms of the Eclipse Public License 2.0 which is available at
9 * http://www.eclipse.org/legal/epl-2.0
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.lametrictime.internal.api.impl;
15 import java.util.Base64;
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.eclipse.jdt.annotation.Nullable;
19 import org.openhab.binding.lametrictime.internal.api.dto.Icon;
22 * Implementation class for icons.
24 * @author Gregory Moyer - Initial contribution
27 public abstract class AbstractDataIcon implements Icon {
29 private volatile Object CONFIGURE_FLAG;
34 private byte @Nullable [] data;
36 protected void configure() {
37 if (CONFIGURE_FLAG == null) {
39 if (CONFIGURE_FLAG == null) {
46 protected @Nullable String getType() {
51 protected void setType(String type) {
55 protected byte @Nullable [] getData() {
60 protected void setData(byte[] data) {
65 public String toRaw() {
66 return new StringBuilder().append("data:").append(getType()).append(";base64,")
67 .append(Base64.getEncoder().encodeToString(getData())).toString();
70 protected abstract void populateFields();