private boolean hasFileBytesInfoIfNeeded() {

		if (initializedType != InitializedType.INITIALIZED_FROM_FILE_BYTES) {
			return true;
		}

		if (fileBytes == null) {
			message = "Please select a FileBytes entry";
			return false;
		}

		if (fileBytesOffset < 0 || fileBytesOffset >= fileBytes.getSize()) {
			message =
				"Please enter a valid file bytes offset (0 - " + (fileBytes.getSize() - 1) + ")";
			return false;
		}

		if (fileBytesOffset + length > fileBytes.getSize()) {
			message = "File bytes offset + length exceeds file bytes size: " + fileBytes.getSize();
			return false;
		}
		return true;
	}
Model to manage adding a memory block.
Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/memory/AddBlockModel.java