mvvmfx/src/main/java/de/saxsys/mvvmfx/internal/viewloader/ResourceBundleInjector.java
static void injectResourceBundle(Object target, ResourceBundle resourceBundle) {
		final List<Field> fieldsWithAnnotation = ReflectionUtils
				.getFieldsWithAnnotation(target, InjectResourceBundle.class);
		
		final boolean notAssignableFieldPresent = fieldsWithAnnotation.stream()
				.anyMatch(field -> !field.getType().isAssignableFrom(ResourceBundle.class));
		
		if (notAssignableFieldPresent) {
			throw new IllegalStateException(
					"The class ["
							+ target
							+ "] has at least one field with the annotation @InjectResourceBundle but the field is not of type ResourceBundle.");
		}
		
		// check whether the user has provided any resourceBundle or not
		if (resourceBundle == null || resourceBundle.equals(EMPTY_RESOURCE_BUNDLE)) {
			
			if (!fieldsWithAnnotation.isEmpty()) {
				
				final boolean nonOptionalFieldsPresent = fieldsWithAnnotation.stream()
						.flatMap(field -> Arrays.stream(field.getAnnotationsByType(InjectResourceBundle.class)))
						.anyMatch(annotation -> !annotation.optional());
				
				// if all annotated fields are marked as "optional", no exception has to be thrown.
				if (nonOptionalFieldsPresent) {
					throw new IllegalStateException(
							"The class ["
									+ target
									+ "] expects a ResourceBundle to be injected but no ResourceBundle was defined while loading.");
				}
			}
		} else {
			fieldsWithAnnotation
					.forEach(field -> {
						if (field.getType().isAssignableFrom(ResourceBundle.class)) {
							ReflectionUtils.setField(field, target, resourceBundle);
						} else {
							throw new IllegalStateException(
									"The class ["
											+ target
											+ "] has a field with the @InjectResourceBundle annotation but the type of the field doesn't match ResourceBundle");
						}
					});
		}
	}
static void injectResourceBundle(Object target, ResourceBundle resourceBundle) {
		final List<Field> fieldsWithAnnotation = ReflectionUtils
				.getFieldsWithAnnotation(target, InjectResourceBundle.class);
		
		final boolean notAssignableFieldPresent = fieldsWithAnnotation.stream()
				.anyMatch(field -> !field.getType().isAssignableFrom(ResourceBundle.class));
		
		if (notAssignableFieldPresent) {
			throw new IllegalStateException(
					"The class ["
							+ target
							+ "] has at least one field with the annotation @InjectResourceBundle but the field is not of type ResourceBundle.");
		}
		
		// check whether the user has provided any resourceBundle or not
		if (resourceBundle == null || resourceBundle.equals(EMPTY_RESOURCE_BUNDLE)) {
			
			if (!fieldsWithAnnotation.isEmpty()) {
				
				final boolean nonOptionalFieldsPresent = fieldsWithAnnotation.stream()
						.flatMap(field -> Arrays.stream(field.getAnnotationsByType(InjectResourceBundle.class)))
						.anyMatch(annotation -> !annotation.optional());
				
				// if all annotated fields are marked as "optional", no exception has to be thrown.
				if (nonOptionalFieldsPresent) {
					throw new IllegalStateException(
							"The class ["
									+ target
									+ "] expects a ResourceBundle to be injected but no ResourceBundle was defined while loading.");
				}
			}
		} else {
			fieldsWithAnnotation
					.forEach(field -> {
						if (field.getType().isAssignableFrom(ResourceBundle.class)) {
							ReflectionUtils.setField(field, target, resourceBundle);
						} else {
							throw new IllegalStateException(
									"The class ["
											+ target
											+ "] has a field with the @InjectResourceBundle annotation but the type of the field doesn't match ResourceBundle");
						}
					});
		}
	}
Try to inject the given {@link ResourceBundle} into the given target instance.

@param target
the View/ViewModel instance that the ResourceBundle will be injected to. May not be <code>null</code>.
@param resourceBundle
the ResourceBundle instance that is used.