You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

PackExt.java 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * Copyright (C) 2013, Google Inc. and others
  3. *
  4. * This program and the accompanying materials are made available under the
  5. * terms of the Eclipse Distribution License v. 1.0 which is available at
  6. * https://www.eclipse.org/org/documents/edl-v10.php.
  7. *
  8. * SPDX-License-Identifier: BSD-3-Clause
  9. */
  10. package org.eclipse.jgit.internal.storage.pack;
  11. /**
  12. * A pack file extension.
  13. */
  14. public enum PackExt {
  15. /** A pack file extension. */
  16. PACK("pack"), //$NON-NLS-1$
  17. /** A pack index file extension. */
  18. INDEX("idx"), //$NON-NLS-1$
  19. /** A keep pack file extension. */
  20. KEEP("keep"), //$NON-NLS-1$
  21. /** A pack bitmap index file extension. */
  22. BITMAP_INDEX("bitmap"), //$NON-NLS-1$
  23. /** A reftable file. */
  24. REFTABLE("ref"); //$NON-NLS-1$
  25. private final String ext;
  26. private PackExt(String ext) {
  27. this.ext = ext;
  28. }
  29. /**
  30. * Get the file extension.
  31. *
  32. * @return the file extension.
  33. */
  34. public String getExtension() {
  35. return ext;
  36. }
  37. /**
  38. * Get the position of the extension in the enum declaration.
  39. *
  40. * @return the position of the extension in the enum declaration.
  41. */
  42. public int getPosition() {
  43. return ordinal();
  44. }
  45. /**
  46. * Get the bit mask of the extension e.g {@code 1 << getPosition()}.
  47. *
  48. * @return the bit mask of the extension e.g {@code 1 << getPosition()}.
  49. */
  50. public int getBit() {
  51. return 1 << getPosition();
  52. }
  53. /** {@inheritDoc} */
  54. @Override
  55. public String toString() {
  56. return String.format("PackExt[%s, bit=0x%s]", getExtension(), //$NON-NLS-1$
  57. Integer.toHexString(getBit()));
  58. }
  59. }