YmlProvider

This commit is contained in:
redkale
2024-08-14 17:02:59 +08:00
parent d69412b1f8
commit 483244bda2
3 changed files with 15 additions and 10 deletions

View File

@@ -1164,4 +1164,8 @@ public abstract class AnyValue {
sb.append('}');
return sb.toString();
}
public Properties toProperties() {
throw new UnsupportedOperationException("Not supported yet.");
}
}

View File

@@ -14,12 +14,9 @@ package org.redkale.util;
*/
public interface YmlProvider {
public static final YmlProvider NIL = c -> {
throw new UnsupportedOperationException("Not supported yet.");
};
/**
* 将yml内容转换成AnyValue
*
* @param content yml内容
* @return AnyValue
*/

View File

@@ -31,11 +31,7 @@ public class YmlReader {
}
public AnyValue read() {
YmlProvider provider = loadProvider();
if (provider == YmlProvider.NIL) {
throw new UnsupportedOperationException("Not supported yml.");
}
return provider.read(text);
return loadProvider().read(text);
}
/**
@@ -60,8 +56,16 @@ public class YmlReader {
currentProvider = provider;
return provider;
}
currentProvider = YmlProvider.NIL;
currentProvider = new DefaultYmlProvider();
}
return currentProvider;
}
protected static class DefaultYmlProvider implements YmlProvider {
@Override
public AnyValue read(String content) {
throw new UnsupportedOperationException("Not supported yml.");
}
}
}