Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

AliasesModule.java 2.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. * Copyright (c) 2006-2017 DMDirc Developers
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
  5. * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
  6. * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
  7. * permit persons to whom the Software is furnished to do so, subject to the following conditions:
  8. *
  9. * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
  10. * Software.
  11. *
  12. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  13. * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
  14. * OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  15. * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  16. */
  17. package com.dmdirc.commandparser.aliases;
  18. import com.dmdirc.commandline.CommandLineOptionsModule.Directory;
  19. import com.dmdirc.commandline.CommandLineOptionsModule.DirectoryType;
  20. import com.dmdirc.util.system.Migrator;
  21. import com.dmdirc.util.system.SystemLifecycleComponent;
  22. import java.nio.file.Path;
  23. import javax.inject.Singleton;
  24. import dagger.Module;
  25. import dagger.Provides;
  26. /**
  27. * Dagger module for aliases.
  28. */
  29. @Module(library = true, complete = false)
  30. public class AliasesModule {
  31. @Provides
  32. @Singleton
  33. public AliasStore getAliasStore(
  34. @Directory(DirectoryType.BASE) final Path directory,
  35. final AliasFactory factory) {
  36. return new YamlAliasStore(directory.resolve("aliases.yml"), factory);
  37. }
  38. @Provides(type = Provides.Type.SET)
  39. public SystemLifecycleComponent getLifecycleComponent(final AliasLifecycleManager manager) {
  40. return manager;
  41. }
  42. @Provides(type = Provides.Type.SET)
  43. public Migrator getActionMigrator(final ActionAliasMigrator migrator) {
  44. return migrator;
  45. }
  46. @Provides(type = Provides.Type.SET)
  47. public Migrator getDefaultsMigrator(@Directory(DirectoryType.BASE) final Path directory) {
  48. return new DefaultAliasInstaller(directory.resolve("aliases.yml"));
  49. }
  50. }