mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
get rid of NullStateStorage, NullStateSplitter, NullStateStorageChooser
This commit is contained in:
+3
-8
@@ -320,15 +320,10 @@ public abstract class ComponentStoreImpl implements IComponentStore {
|
||||
}
|
||||
assert storages.length > 0;
|
||||
|
||||
final Class<StorageAnnotationsDefaultValues.NullStateStorageChooser> defaultClass =
|
||||
StorageAnnotationsDefaultValues.NullStateStorageChooser.class;
|
||||
|
||||
final Class<? extends StateStorageChooser> storageChooserClass = stateSpec.storageChooser();
|
||||
final StateStorageChooser<PersistentStateComponent<?>> defaultStateStorageChooser = getDefaultStateStorageChooser();
|
||||
assert storageChooserClass != defaultClass || defaultStateStorageChooser != null : "State chooser not specified for: " +
|
||||
persistentStateComponent.getClass();
|
||||
|
||||
if (storageChooserClass == defaultClass) {
|
||||
if (storageChooserClass == StateStorageChooser.class) {
|
||||
StateStorageChooser<PersistentStateComponent<?>> defaultStateStorageChooser = getDefaultStateStorageChooser();
|
||||
assert defaultStateStorageChooser != null : "State chooser not specified for: " + persistentStateComponent.getClass();
|
||||
return defaultStateStorageChooser.selectStorages(storages, persistentStateComponent, operation);
|
||||
}
|
||||
else if (storageChooserClass == LastStorageChooserForWrite.class) {
|
||||
|
||||
+2
-2
@@ -680,12 +680,12 @@ class ProjectStoreImpl extends BaseFileConfigurableStoreImpl implements IProject
|
||||
|
||||
@Override
|
||||
public Class<? extends StateStorage> storageClass() {
|
||||
return StorageAnnotationsDefaultValues.NullStateStorage.class;
|
||||
return StateStorage.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends StateSplitter> stateSplitter() {
|
||||
return StorageAnnotationsDefaultValues.NullStateSplitter.class;
|
||||
return StateSplitter.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+3
-3
@@ -176,19 +176,19 @@ public abstract class StateStorageManagerImpl implements StateStorageManager, Di
|
||||
|
||||
@Nullable
|
||||
private StateStorage createStateStorage(Storage storageSpec) throws StateStorageException {
|
||||
if (!storageSpec.storageClass().equals(StorageAnnotationsDefaultValues.NullStateStorage.class)) {
|
||||
if (!storageSpec.storageClass().equals(StateStorage.class)) {
|
||||
String key = UUID.randomUUID().toString();
|
||||
((MutablePicoContainer)myPicoContainer).registerComponentImplementation(key, storageSpec.storageClass());
|
||||
return (StateStorage)myPicoContainer.getComponentInstance(key);
|
||||
}
|
||||
if (!storageSpec.stateSplitter().equals(StorageAnnotationsDefaultValues.NullStateSplitter.class)) {
|
||||
if (!storageSpec.stateSplitter().equals(StateSplitter.class)) {
|
||||
return createDirectoryStateStorage(storageSpec.file(), storageSpec.stateSplitter());
|
||||
}
|
||||
return createFileStateStorage(storageSpec.file());
|
||||
}
|
||||
|
||||
private static String getStorageSpecId(Storage storageSpec) {
|
||||
if (!storageSpec.storageClass().equals(StorageAnnotationsDefaultValues.NullStateStorage.class)) {
|
||||
if (!storageSpec.storageClass().equals(StateStorage.class)) {
|
||||
return storageSpec.storageClass().getName();
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -32,7 +32,7 @@ public @interface State {
|
||||
|
||||
Storage[] storages();
|
||||
|
||||
Class<? extends StateStorageChooser> storageChooser() default StorageAnnotationsDefaultValues.NullStateStorageChooser.class;
|
||||
Class<? extends StateStorageChooser> storageChooser() default StateStorageChooser.class;
|
||||
|
||||
boolean reloadable() default true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,6 @@ public @interface Storage {
|
||||
@NonNls String file() default "";
|
||||
StorageScheme scheme() default StorageScheme.DEFAULT;
|
||||
|
||||
Class<? extends StateStorage> storageClass() default StorageAnnotationsDefaultValues.NullStateStorage.class;
|
||||
Class<? extends StateSplitter> stateSplitter() default StorageAnnotationsDefaultValues.NullStateSplitter.class;
|
||||
Class<? extends StateStorage> storageClass() default StateStorage.class;
|
||||
Class<? extends StateSplitter> stateSplitter() default StateSplitter.class;
|
||||
}
|
||||
|
||||
-87
@@ -1,87 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.intellij.openapi.components;
|
||||
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public interface StorageAnnotationsDefaultValues {
|
||||
class NullStateStorage implements StateStorage {
|
||||
@Override
|
||||
@Nullable
|
||||
public <T> T getState(final Object component, final String componentName, Class<T> stateClass, @Nullable T mergeInto)
|
||||
throws StateStorageException {
|
||||
throw new UnsupportedOperationException("Method getState is not supported in " + getClass());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasState(final Object component, final String componentName, final Class<?> aClass, final boolean reloadData) throws StateStorageException {
|
||||
throw new UnsupportedOperationException("Method hasState not implemented in " + getClass());
|
||||
}
|
||||
|
||||
public void save() throws StateStorageException {
|
||||
throw new UnsupportedOperationException("Method save is not supported in " + getClass());
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public ExternalizationSession startExternalization() {
|
||||
throw new UnsupportedOperationException("Method startExternalization not implemented in " + getClass());
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public SaveSession startSave(@NotNull ExternalizationSession externalizationSession) {
|
||||
throw new UnsupportedOperationException("Method startSave not implemented in " + getClass());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finishSave(@NotNull SaveSession saveSession) {
|
||||
throw new UnsupportedOperationException("Method finishSave not implemented in " + getClass());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reload(@NotNull final Set<String> changedComponents) throws StateStorageException {
|
||||
throw new UnsupportedOperationException("Method reload not implemented in " + getClass());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class NullStateStorageChooser implements StateStorageChooser {
|
||||
@Override
|
||||
public Storage[] selectStorages(Storage[] storages, Object component, final StateStorageOperation operation) {
|
||||
throw new UnsupportedOperationException("Method selectStorages is not supported in " + getClass());
|
||||
}
|
||||
}
|
||||
|
||||
class NullStateSplitter implements StateSplitter {
|
||||
@Override
|
||||
public List<Pair<Element, String>> splitState(Element e) {
|
||||
throw new UnsupportedOperationException("Method splitState not implemented in " + getClass());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mergeStatesInto(final Element target, final Element[] elements) {
|
||||
throw new UnsupportedOperationException("Method mergeStatesInto not implemented in " + getClass());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user