public static ETagManager createETagManager()

in polaris-synchronizer/cli/src/main/java/org/apache/polaris/tools/sync/polaris/ETagManagerFactory.java [36:65]


    public static ETagManager createETagManager(Type type, Map<String, String> properties) {
        try {
            properties = properties == null ? new HashMap<>() : properties;

            ETagManager manager = switch (type) {
                case NONE -> new NoOpETagManager();
                case FILE -> new CsvETagManager();
                case CUSTOM -> {
                    String customManagerClassname = properties.get(CUSTOM_CLASS_NAME_PROPERTY);

                    if (customManagerClassname == null) {
                        throw new IllegalArgumentException("Missing required property " + CUSTOM_CLASS_NAME_PROPERTY);
                    }

                    Object custom = Class.forName(customManagerClassname).getDeclaredConstructor().newInstance();

                    if (custom instanceof ETagManager customManager) {
                        yield customManager;
                    }

                    throw new InstantiationException("Custom ETagManager '" + customManagerClassname + "' does not implement ETagManager");
                }
            };

            manager.initialize(properties);
            return manager;
        } catch (Exception e) {
            throw new RuntimeException("Failed to construct ETagManager", e);
        }
    }