4bed0154d07d5a0e843eb425eeb2534c277d17f2
[chesshog.git] / src / main / java / org / hedgecode / chess / img / AbstractImageLoader.java
1 /*
2  * Copyright (c) 2018-2019. Developed by Hedgecode.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *   http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 package org.hedgecode.chess.img;
18
19 import java.io.File;
20
21 /**
22  *
23  *
24  * @author Dmitry Samoshin aka gotty
25  */
26 public abstract class AbstractImageLoader implements ImageLoader {
27
28     protected static final File IMAGES_PATH = new File(
29             ImageLoader.class.getResource(
30                     ImageConstants.RESOURCE_ROOT_DIR + ImageConstants.RESOURCE_IMAGES_DIR
31             ).getPath()
32     );
33
34     private Type loadType;
35
36     public AbstractImageLoader() {
37         this.loadType = Type.STATELESS;
38     }
39
40     protected abstract void clear();
41
42     @Override
43     public Type loadType() {
44         return loadType;
45     }
46
47     protected void setLoadType(Type loadType) {
48         if (Type.STATELESS.equals(loadType)) {
49             clear();
50         }
51         this.loadType = loadType;
52     }
53
54 }