content: /*
   * Copyright (C) 2016-2023 ActionTech.
   * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher.
   */
  
  package com.actiontech.dble.route.util;
  
  import java.util.*;
  
  public class OrderedProperties extends Properties {
      private static final long serialVersionUID = -4627607243846121965L;
  
      private final LinkedHashSet<Object> keys = new LinkedHashSet<>();
  
      @Override
      public synchronized Enumeration<Object> keys() {
          return Collections.enumeration(keys);
      }
  
      @Override
      public synchronized Object put(Object key, Object value) {
          keys.add(key);
          return super.put(key, value);
      }
  
      @Override
      public Set<String> stringPropertyNames() {
          Set<String> set = new LinkedHashSet<>();
          for (Object key : this.keys) {
              set.add((String) key);
          }
          return set;
      }
  
      @Override
      public Set<Object> keySet() {
          return keys;
      }
  
      @Override
      public Enumeration<?> propertyNames() {
          return Collections.enumeration(keys);
      }
  
      @Override
      public synchronized boolean equals(Object o) {
          return super.equals(o);
      }
  
      @Override
      public synchronized int hashCode() {
          return super.hashCode();
      }
  }
  